mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
JSONfeed
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fontsource/fira-mono": "^4.5.10",
|
"@fontsource/fira-mono": "^4.5.10",
|
||||||
|
"@json-feed-types/1_1": "^1.0.2",
|
||||||
"@neoconfetti/svelte": "^1.0.0",
|
"@neoconfetti/svelte": "^1.0.0",
|
||||||
"@sveltejs/adapter-auto": "^3.0.0",
|
"@sveltejs/adapter-auto": "^3.0.0",
|
||||||
"@sveltejs/adapter-node": "^4.0.1",
|
"@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)
|
||||||
|
}
|
||||||
Generated
+19
@@ -23,6 +23,9 @@ importers:
|
|||||||
'@fontsource/fira-mono':
|
'@fontsource/fira-mono':
|
||||||
specifier: ^4.5.10
|
specifier: ^4.5.10
|
||||||
version: 4.5.10
|
version: 4.5.10
|
||||||
|
'@json-feed-types/1_1':
|
||||||
|
specifier: ^1.0.2
|
||||||
|
version: 1.0.2
|
||||||
'@neoconfetti/svelte':
|
'@neoconfetti/svelte':
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
@@ -538,6 +541,17 @@ packages:
|
|||||||
'@jridgewell/sourcemap-codec': 1.4.15
|
'@jridgewell/sourcemap-codec': 1.4.15
|
||||||
dev: true
|
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:
|
/@neoconfetti/svelte@1.0.0:
|
||||||
resolution: {integrity: sha512-SmksyaJAdSlMa9cTidVSIqYo1qti+WTsviNDwgjNVm+KQ3DRP2Df9umDIzC4vCcpEYY+chQe0i2IKnLw03AT8Q==}
|
resolution: {integrity: sha512-SmksyaJAdSlMa9cTidVSIqYo1qti+WTsviNDwgjNVm+KQ3DRP2Df9umDIzC4vCcpEYY+chQe0i2IKnLw03AT8Q==}
|
||||||
dev: true
|
dev: true
|
||||||
@@ -2229,6 +2243,11 @@ packages:
|
|||||||
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
|
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/type-fest@2.19.0:
|
||||||
|
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
|
||||||
|
engines: {node: '>=12.20'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/typescript@5.3.3:
|
/typescript@5.3.3:
|
||||||
resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==}
|
resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==}
|
||||||
engines: {node: '>=14.17'}
|
engines: {node: '>=14.17'}
|
||||||
|
|||||||
Reference in New Issue
Block a user