added RSS feed for devlog
This commit is contained in:
@@ -45,6 +45,8 @@
|
||||
<Content>
|
||||
<h1 class="gradient-title"><i>Moin!</i> ~ welcome to my website :)</h1>
|
||||
|
||||
<a href="/projects/projectn5/devlog/feed/">feed here</a>
|
||||
|
||||
<div class="container">
|
||||
<div class="subcontainer">
|
||||
<Gallery entries={[
|
||||
|
||||
30
src/routes/feeds/+page.svelte
Normal file
30
src/routes/feeds/+page.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
import BannerTitleAlt from "$lib/banner-title-alt.svelte";
|
||||
import Content from "$lib/content.svelte";
|
||||
import LinkList, { type LinkEntry } from "$lib/link-list.svelte";
|
||||
|
||||
let feeds: LinkEntry[] = [
|
||||
{
|
||||
text: "Project N5 devlog",
|
||||
link: "/projects/projectn5/devlog/feed.xml",
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Feeds | denizk0461</title>
|
||||
</svelte:head>
|
||||
|
||||
<BannerTitleAlt
|
||||
title="Feeds"
|
||||
banner="/feeds/banner.webp"
|
||||
bannerAlt="Mirror picture of me, pixelated beyond recognition"
|
||||
subtitle="XML feeds"
|
||||
pixelated
|
||||
/>
|
||||
|
||||
<Content>
|
||||
<p>This is a list of RSS feeds I maintain on this website. You can subscribe to them by adding the link of any feed to an RSS reader of your liking.</p>
|
||||
|
||||
<LinkList entries={feeds} />
|
||||
</Content>
|
||||
39
src/routes/projects/projectn5/devlog/feed.xml/+server.ts
Normal file
39
src/routes/projects/projectn5/devlog/feed.xml/+server.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
export const prerender = true;
|
||||
import { posts, type DevlogPost } from "../posts";
|
||||
|
||||
const xml = (tposts: Map<string, DevlogPost>) => `<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:atom="https://www.w3.org/2005/Atom" version="2.0">
|
||||
<channel>
|
||||
<title>denizk0461</title>
|
||||
<link>https://denizk0461.dev/projects/projectn5/devlog/</link>
|
||||
<description><![CDATA[Development log for the game Homesick 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)}]]></pubDate>
|
||||
</item>
|
||||
`)
|
||||
entries.forEach(entry => {
|
||||
val += entry;
|
||||
})
|
||||
return val;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export async function GET() {
|
||||
const headers = {
|
||||
'Cache-Control': 'max-age=0, s-maxage=600',
|
||||
'Content-Type': 'application/xml',
|
||||
};
|
||||
const body = xml(posts);
|
||||
return new Response(body);
|
||||
}
|
||||
BIN
static/feeds/banner.webp
Normal file
BIN
static/feeds/banner.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user