<script lang="ts">
    import Banner2 from "$lib/banner2.svelte";
    import Content from "$lib/viewport/content.svelte";
    // import type { DevlogPost } from "./devlog-posts";
    import { posts, type DevlogPost } from "./devlog/posts";
    import Gallery, { type GalleryEntry } from "$lib/lists/gallery.svelte";

    let allEntries: GalleryEntry[] = posts.entries().map(mapEntries).toArray()
    let entries: GalleryEntry[] = $state(allEntries.slice(0, 3));
    let loadEntryButton: HTMLElement;

    function mapEntries(m: [String, DevlogPost], index: number): GalleryEntry {
        return {
            title: `${m[1].title}`,
            subtitle: `#${posts.size - index} // ${m[1].date}`,
            img: `/projects/projectn5/devlog/${m[0]}/preview.webp`,
            link: `/projects/projectn5/devlog/${m[0]}/`,
            imgAlt: `Preview image for ${m[1].title}`,
        };
    }

    function loadAllEntries() {
        entries = allEntries;
        loadEntryButton.style.display = "none";
    }

    // Leftpads a single-digit number to two digits
    function leftpad(n: number): String {
        var result = n.toString();
        if (n < 10) {
            result = "0" + result
        }
        return result;
    }
</script>


<svelte:head>
    <title>Project N5 | denizk0461</title> 
</svelte:head>

<Content>
    <Banner2
        title="Project N5"
        banner="/projects/projectn5/banner2.webp" />

    <p>I am currently working on a game under the working title <b>Project N5</b>! I'm aiming for it to be an action-adventure jump-and-run game inspired by games such as Ratchet & Clank. Development started on <b>2023-09-16</b> and rebooted on <b>2025-05-16</b>.</p>

    <h2 id="devlog">Development Log</h2>

    <p>Development log entries in reverse chronological order (newest to oldest).</p> 

    <Gallery entries={entries} reverseTextOrder />

    <button class="button-fullwidth" onclick={loadAllEntries} bind:this={loadEntryButton}>Load all entries</button>
</Content>