devlog post metadata is now fetched centrally from posts.ts

This commit is contained in:
2025-12-05 18:24:36 +00:00
parent c2bb3cb927
commit 50f2e259e8
3 changed files with 163 additions and 50 deletions

View File

@@ -1,34 +1,8 @@
<script lang="ts"> <script lang="ts">
import BannerTitleAlt from "$lib/banner-title-alt.svelte"; import BannerTitleAlt from "$lib/banner-title-alt.svelte";
import Content from "$lib/content.svelte"; import Content from "$lib/content.svelte";
import type { DevlogPost } from "./devlog-posts"; // import type { DevlogPost } from "./devlog-posts";
import { posts } from "./devlog-posts"; import { posts, type DevlogPost } from "./posts";
import { onMount } from 'svelte';
interface DevlogLiveEntry {
timestamp: string;
text: string;
}
let entries: DevlogLiveEntry[] = $state([]);
onMount(() => {
getRecentEntries();
});
async function getRecentEntries() {
let response = await fetch("https://server.denizk0461.dev:2761/recentEntries")
let data = await response.json();
data.forEach(datum => {
var date = new Date(datum.Timestamp)
console.log(datum.Timestamp)
entries.push({
timestamp: `${date.getFullYear()}-${leftpad(date.getMonth() + 1)}-${leftpad(date.getDate())} ${leftpad(date.getHours())}:${leftpad(date.getMinutes())}`,
text: datum.Text,
})
});
console.log(data)
};
// Leftpads a single-digit number to two digits // Leftpads a single-digit number to two digits
function leftpad(n: number): String { function leftpad(n: number): String {
@@ -38,6 +12,14 @@
} }
return result; return result;
} }
function getDevlogPosts(): DevlogPost[] {
let posts: DevlogPost[] = [];
return posts;
}
</script> </script>
@@ -57,32 +39,20 @@
<p>2023 progress updates summarise an entire month's work, respectively. Progress updates thereafter denote noteworthy developments in a more collected format.</p> <p>2023 progress updates summarise an entire month's work, respectively. Progress updates thereafter denote noteworthy developments in a more collected format.</p>
<div class="post-container"> <div class="post-container">
{#each posts as post, index} {#each posts.values() as post, index}
{@render devlogPost({post, index})} {@render devlogPost({post, index})}
{/each} {/each}
</div> </div>
</Content> </Content>
{#snippet liveUpdate({entry}: {entry: DevlogLiveEntry})}
<div class="live-devlog-entry notched-small">
<p class="live-devlog-entry-time">{entry.timestamp}</p>
<p class="live-devlog-entry-content">{entry.text}</p>
</div>
{/snippet}
{#snippet devlogPost({post, index}: {post: DevlogPost, index: number})} {#snippet devlogPost({post, index}: {post: DevlogPost, index: number})}
<div class="post-supercontainer"> <div class="post-supercontainer">
<a href="/projects/projectn5/devlog/{post.date}/" class="post"> <a href="/projects/projectn5/devlog/{post.id}/" class="post">
<div class="post-img-container"> <div class="post-img-container">
<img class="post-img" src="/projects/projectn5/devlog/previews/{post.date}.webp" alt="Preview image for devlog {post.title}"> <img class="post-img" src="/projects/projectn5/devlog/{post.id}/preview.webp" alt="Preview image for devlog {post.title}">
<!-- <p class="post-number">#{posts.length - index}</p> -->
</div> </div>
<div class="post-text-container"> <div class="post-text-container">
{#if post.subtitle} <p class="post-date">#{posts.size - index} // {post.date}</p>
<p class="post-date">#{posts.length - index} // {post.subtitle}</p>
{:else}
<p class="post-date">#{posts.length - index} ~</p>
{/if}
<p class="post-title">{post.title}</p> <p class="post-title">{post.title}</p>
</div> </div>
</a> </a>

View File

@@ -1,12 +1,14 @@
import { posts, type DevlogPost } from '../posts';
export async function load({ params }) { export async function load({ params }) {
const post = await import(`../${params.slug}.md`); const post = await import(`../${params.slug}.md`);
const {
title, const tag: string = params.slug;
date, const postValues = posts.get(tag);
tag,
bannerAlt,
} = post.metadata;
const content = post.default; const content = post.default;
const title = postValues?.title;
const date = postValues?.date;
const bannerAlt = postValues?.bannerAlt;
return { return {
content, content,

View File

@@ -0,0 +1,141 @@
export interface DevlogPost {
title: string;
date: string;
id: string;
bannerAlt: string;
};
export const posts = new Map<string, DevlogPost>([
["20251022", {
title: "Growing Pains",
date: "2025-10-22",
id: "20251022",
bannerAlt: "Close-up of Laura blinking",
}],
["20251011", {
title: "She's Here",
date: "2025-10-11",
id: "20251011",
bannerAlt: "Laura idle posing",
}],
["20250816", {
title: "Freeing the Past",
date: "2025-08-16",
id: "20250816",
bannerAlt: "Bottom-up view at Laura v1 in front of a blue sky",
}],
["20250713", {
title: "Remeshing and Recolouring",
date: "2025-07-13",
id: "20250713",
bannerAlt: "Close-up of Laura at face height",
}],
["20250523", {
title: "Reboot",
date: "2025-05-23",
id: "20250523",
bannerAlt: "Untextured Laura in a new purple level looking at two cubes",
}],
["20250427", {
title: "The Making of a Protagonist, Part IV",
date: "2025-04-27",
id: "20250427",
bannerAlt: "Sketches of Laura's new clothes",
}],
["20250316", {
title: "Refactoring",
date: "2025-03-16",
id: "20250316",
bannerAlt: "Laura t-posing in front of a smiling water tower",
}],
["20250203", {
title: "The Making of a Protagonist, Part III",
date: "2025-02-03",
id: "20250203",
bannerAlt: "Three t-posing untextured Lauras",
}],
["20241222", {
title: "The Making of a Protagonist, Part II",
date: "2024-12-22",
id: "20241222",
bannerAlt: "Laura a-posing and wearing green and brown clothes",
}],
["20241127", {
title: "The Making of a Protagonist, Part I",
date: "2024-11-27",
id: "20241127",
bannerAlt: "Multiple iterations of untextured hand 3D models",
}],
["20241103", {
title: "Visual Update",
date: "2024-11-03",
id: "20241103",
bannerAlt: "Two N5 Blaster side-to-side",
}],
["20241012", {
title: "Returnal Update",
date: "2024-10-12",
id: "20241012",
bannerAlt: "Protagonist aiming at two monkeys",
}],
["20240713", {
title: "WHERE HAVE I BEEN?? Update",
date: "2024-07-13",
id: "20240713",
bannerAlt: "Protagonist staring longingly into the distance, pointing the N5 Blaster thereto",
}],
["20240401", {
title: "Behind-The-Scenes Update",
date: "2024-04-01",
id: "20240401",
bannerAlt: "N5 Blaster with its lights turned off",
}],
["20240324", {
title: "Arena Update",
date: "2024-03-24",
id: "20240324",
bannerAlt: "Protagonist being swamped by many monkey enemies",
}],
["20240323", {
title: "Progress Update #7",
date: "2024-03-23",
id: "20240323",
bannerAlt: "A red enemy being blown up by an incoming rocket",
}],
["20240312", {
title: "Progress Update #6",
date: "2024-03-12",
id: "20240312",
bannerAlt: "Protagonist pointing the N5 Blaster into the sky",
}],
["20240210", {
title: "Progress Update #5",
date: "2024-02-10",
id: "20240210",
bannerAlt: "Panorama of the environment",
}],
["202312", {
title: "Progress Update #4",
date: "2023-12",
id: "202312",
bannerAlt: "White protagonist holding the N5 Blaster",
}],
["202311", {
title: "Progress Update #3",
date: "2023-11",
id: "202311",
bannerAlt: "A side view of the N5 Blaster",
}],
["202310", {
title: "Progress Update #2",
date: "2023-10",
id: "202310",
bannerAlt: "Red protagonist lying on the floor, holding a purple blaster",
}],
["202309", {
title: "Progress Update #1",
date: "2023-09",
id: "202309",
bannerAlt: "Ratchet from Ratchet: Gladiator and Sans from Undertale t-posing",
}],
])