<script lang="ts">
    import BannerTitleAlt from "$lib/banner-title-alt.svelte";
    import TableOfContents from "$lib/table-of-contents.svelte";
    import Content from "$lib/content.svelte";
    import type { Project } from '$lib/projects';
    import { projects } from '$lib/projects';
    import LinkList from "$lib/link-list.svelte";

    let getActiveProjects = function(projects: Project[], isActive: boolean): Project[] {
        var result: Project[] = [];
        projects.forEach(project => {
            if (project.isActive == isActive) {
                result.push(project);
            }
        });
        return result;
    }
</script>

<svelte:head>
    <title>Projects | denizk0461</title> 
</svelte:head>

<BannerTitleAlt
    title="My Disordered Projects"
    banner="/projects/banner.webp"
    subtitle="Things I have worked on"
/>

<Content>
    <TableOfContents disableStickyScrolling={true} />

    <h2>Active Projects</h2>
    {#each getActiveProjects(projects, true) as activeProject}
        {@render projectSummary({ project: activeProject })}
    {/each}

    <h2>Past Projects</h2>
    {#each getActiveProjects(projects, false) as pastProject}
        {@render projectSummary({ project: pastProject })}
    {/each}
</Content>

{#snippet projectSummary({
    project
}: {
    project: Project;
})}
    <div>
        <h3 id="{project.id}">{project.title}</h3>
        {#if project.subtitle}
        <p class="project-subtitle">» {project.subtitle}</p>
        {/if}
        {#if project.banner}
        <div class="project-banner-container">
            <img class="project-banner" src="{project.banner}">
            {#if project.date}
            <p class="project-date project-date-embed">{project.date}</p>
            {/if}
        </div>
        {:else}
        {#if project.date}
        <p class="project-date">{project.date}</p>
        {/if}
        {/if}
        {#if project.icon}
        <img class="project-icon" src="{project.icon}">
        {/if}
        {#each project.paragraphs as paragraph}
            <p>{@html paragraph}</p>
        {/each}
        <LinkList entries={project.links} />
    </div>
{/snippet}