JSONfeed
This commit is contained in:
parent
bdb0bdee2d
commit
a82ca7b1c0
3 changed files with 75 additions and 0 deletions
|
|
@ -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",
|
||||
|
|
|
|||
55
packages/website/src/routes/feed.json/+server.ts
Normal file
55
packages/website/src/routes/feed.json/+server.ts
Normal file
|
|
@ -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)
|
||||
}
|
||||
19
pnpm-lock.yaml
generated
19
pnpm-lock.yaml
generated
|
|
@ -23,6 +23,9 @@ importers:
|
|||
'@fontsource/fira-mono':
|
||||
specifier: ^4.5.10
|
||||
version: 4.5.10
|
||||
'@json-feed-types/1_1':
|
||||
specifier: ^1.0.2
|
||||
version: 1.0.2
|
||||
'@neoconfetti/svelte':
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
|
|
@ -538,6 +541,17 @@ packages:
|
|||
'@jridgewell/sourcemap-codec': 1.4.15
|
||||
dev: true
|
||||
|
||||
/@json-feed-types/1_1@1.0.2:
|
||||
resolution: {integrity: sha512-Ht6Qm53qhWZvvPat4vScXSxiD3MdULuSZrOzUWgMPuez6HMcv5BQcb0OFvIH6WxH72rE8mZTWHrE2FF22XIAgg==}
|
||||
dependencies:
|
||||
'@json-feed-types/common': 1.0.2
|
||||
type-fest: 2.19.0
|
||||
dev: true
|
||||
|
||||
/@json-feed-types/common@1.0.2:
|
||||
resolution: {integrity: sha512-IWcSEjI+2bjl1T0R4cIPHu2DZ6PF/unRdEl9VZ1vTtLNaybzirGCywat+KLIpbmxrg48kRNgasH4CBYkq99NDw==}
|
||||
dev: true
|
||||
|
||||
/@neoconfetti/svelte@1.0.0:
|
||||
resolution: {integrity: sha512-SmksyaJAdSlMa9cTidVSIqYo1qti+WTsviNDwgjNVm+KQ3DRP2Df9umDIzC4vCcpEYY+chQe0i2IKnLw03AT8Q==}
|
||||
dev: true
|
||||
|
|
@ -2229,6 +2243,11 @@ packages:
|
|||
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
|
||||
dev: true
|
||||
|
||||
/type-fest@2.19.0:
|
||||
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
|
||||
engines: {node: '>=12.20'}
|
||||
dev: true
|
||||
|
||||
/typescript@5.3.3:
|
||||
resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==}
|
||||
engines: {node: '>=14.17'}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue