fixed project n5 and blog XML feed generation

This commit is contained in:
2026-02-03 16:38:38 +01:00
parent 68066923f0
commit 6ae4ae959c
3 changed files with 38 additions and 37 deletions

View File

@@ -1,26 +1,25 @@
export const prerender = true;
import { posts, type BlogPostDetails } from "../posts";
import { posts } from "../posts";
const xml = (tposts: Map<string, BlogPostDetails>) => `<rss version="2.0">
const xml = () => `<rss version="2.0">
<channel>
<title>denizk0461's Blog</title>
<link>https://denizk0461.dev/blog/</link>
<description><![CDATA[denizk0461 blogs about stuff here]]></description>
${getEntries()}
<description><![CDATA[denizk0461 blogs about stuff here]]></description>${getEntries()}
</channel>
</rss>`;
function getEntries(): String {
var val = "";
var entries = posts.entries().map((post, index) =>
`<item>
<title><![CDATA[${post[1].title}]]></title>
<description><![CDATA[${post[1].description}]]></description>
<link>https://denizk0461.dev/blog/${post[0]}</link>
<guid isPermaLink="true">https://denizk0461.dev/blog/${post[0]}</guid>
<pubDate><![CDATA[${new Date(`${post[1].date}T${post[1].time}`).toUTCString()}]]></pubDate>
</item>
`)
var entries = posts.map((entry, _) =>
`
<item>
<title><![CDATA[${entry.post.title}]]></title>
<description><![CDATA[${entry.post.description}]]></description>
<link>https://denizk0461.dev/blog/${entry.key}</link>
<guid isPermaLink="true">https://denizk0461.dev/blog/${entry.key}</guid>
<pubDate><![CDATA[${new Date(`${entry.post.date}T${entry.post.time}`).toUTCString()}]]></pubDate>
</item>`)
entries.forEach(entry => {
val += entry;
})
@@ -33,6 +32,6 @@ export async function GET() {
'Cache-Control': 'max-age=0, s-maxage=600',
'Content-Type': 'application/xml',
};
const body = xml(posts);
const body = xml();
return new Response(body);
}

View File

@@ -6,6 +6,7 @@ export interface BlogPostDetails {
// Banner image title. If empty, defaults to banner.webp
banner: string;
bannerAlt: string;
title: string;
@@ -35,8 +36,9 @@ export const posts: BlogPostLink[] = [
date: "2026-01-31",
time: "20:24",
banner: "colossus.webp",
bannerAlt: "Colossus standing in the National Museum of Computing in Bletchley, UK",
title: "Lessons Learned",
description: "Colossus standing in the National Museum of Computing in Bletchley, UK.",
description: "A small note about how you should always check whether your finished work works as intended.",
}
},
{
@@ -45,6 +47,7 @@ export const posts: BlogPostLink[] = [
date: "2026-01-29",
time: "16:42",
banner: "girl.webp",
bannerAlt: "A small drawing of an anime-style girl's head.",
title: "Limitations",
description: "Something about how boundaries can foster creativity.",
}

View File

@@ -1,26 +1,25 @@
export const prerender = true;
import { posts, type DevlogPost } from "../posts";
import { posts } from "../posts";
const xml = (tposts: Map<string, DevlogPost>) => `<rss version="2.0">
const xml = () => `<rss version="2.0">
<channel>
<title>Project N5 Devlog</title>
<link>https://denizk0461.dev/projects/projectn5/devlog/</link>
<description><![CDATA[Development log for the game Homesick by denizk0461]]></description>
${getEntries()}
<description><![CDATA[Development log for the game Project N5 by denizk0461]]></description>${getEntries()}
</channel>
</rss>`;
function getEntries(): String {
var val = "";
var entries = posts.entries().map((post, index) =>
`<item>
<title><![CDATA[${post[1].title}]]></title>
<description><![CDATA[${post[1].description}]]></description>
<link>https://denizk0461.dev/projects/projectn5/devlog/${post[0]}</link>
<guid isPermaLink="true">https://denizk0461.dev/projects/projectn5/devlog/${post[0]}</guid>
<pubDate><![CDATA[${new Date(post[1].date).toUTCString()}]]></pubDate>
</item>
`)
var entries = posts.map((entry, _) =>
`
<item>
<title><![CDATA[${entry.post.title}]]></title>
<description><![CDATA[${entry.post.description}]]></description>
<link>https://denizk0461.dev/projects/projectn5/devlog/${entry.key}</link>
<guid isPermaLink="true">https://denizk0461.dev/projects/projectn5/devlog/${entry.key}</guid>
<pubDate><![CDATA[${new Date(entry.post.date).toUTCString()}]]></pubDate>
</item>`)
entries.forEach(entry => {
val += entry;
})
@@ -33,6 +32,6 @@ export async function GET() {
'Cache-Control': 'max-age=0, s-maxage=600',
'Content-Type': 'application/xml',
};
const body = xml(posts);
const body = xml();
return new Response(body);
}