This commit is contained in:
Jade Ellis
2024-04-06 14:55:47 +01:00
parent bdb0bdee2d
commit a82ca7b1c0
3 changed files with 75 additions and 0 deletions
+1
View File
@@ -10,6 +10,7 @@
},
"devDependencies": {
"@fontsource/fira-mono": "^4.5.10",
"@json-feed-types/1_1": "^1.0.2",
"@neoconfetti/svelte": "^1.0.0",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-node": "^4.0.1",
@@ -0,0 +1,55 @@
import type Feed from '@json-feed-types/1_1'
import {
SITE_DEFAULT_DESCRIPTION,
SITE_TITLE,
SITE_URL,
RSS_DEFAULT_POSTS_PER_PAGE
} from '$lib/metadata';
import { create } from 'xmlbuilder2';
// import { base } from '$app/paths';
export const prerender = true;
export async function GET() {
const headers = {
'Cache-Control': 'max-age=0, s-maxage=3600',
'Content-Type': 'application/feed+json'
};
return new Response(await getJsonFeed(), { headers });
}
const AUTHOR = "Jade Ellis"
// prettier-ignore
async function getJsonFeed(): Promise<string> {
const feedUrl = `${SITE_URL}/feed.json`;
const feed: Feed = {
version: 'https://jsonfeed.org/version/1.1',
title: SITE_TITLE,
icon: `${SITE_URL}/android-chrome-256x256.png`,
home_page_url: SITE_URL,
description: SITE_DEFAULT_DESCRIPTION,
feed_url: feedUrl,
authors: [{ name: AUTHOR }],
items: [
],
}
// for await (const post of posts) {
// const pubDate =
// const postUrl =
// const postHtml =
// const summary = post.metadata.description;
// root.ele('entry')
// .ele('title').txt(post.metadata.title).up()
// .ele('link', { href: postUrl }).up()
// .ele('updated').txt(pubDate).up()
// .ele('id').txt(postUrl).up()
// .ele('content', { type: 'html' }).txt(postHtml).up()
// .ele('summary').txt(summary).up()
// .up();
// }
return JSON.stringify(feed)
}