From 3be02ece9a82dee8c1df47b9cb7a17298ad04140 Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Thu, 25 Aug 2022 10:27:29 +0200 Subject: [PATCH] fix the rss feed --- package.json | 10 +++++----- pnpm-lock.yaml | 10 +++++----- src/routes/posts/rss.xml/+server.js | 18 ++++++++++-------- svelte.config.js | 5 ++++- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index effdd1f..3f97f6f 100644 --- a/package.json +++ b/package.json @@ -12,16 +12,16 @@ "@sveltejs/kit": "1.0.0-next.431", "mdsvex": "0.10.5", "svelte": "3.46.4", - "vite-plugin-windicss": "^1.8.6" + "vite-plugin-windicss": "^1.8.7" }, "type": "module", "dependencies": { "@sveltejs/pancake": "^0.0.18", "katex": "0.15.2", "luxon": "2.3.1", - "mdast-util-gfm-table": "^1.0.1", - "micromark": "^3.0.5", - "micromark-extension-gfm-table": "^1.0.3", + "mdast-util-gfm-table": "^1.0.4", + "micromark": "^3.0.10", + "micromark-extension-gfm-table": "^1.0.5", "rehype-autolink-headings": "6.1.1", "rehype-katex-svelte": "1.0.3", "rehype-slug": "5.0.1", @@ -31,7 +31,7 @@ "remark-parse": "10.0.1", "remark-twemoji": "0.1.1", "twemoji": "13.1.0", - "unified": "^10.1.0", + "unified": "^10.1.2", "vite": "^3.0.9", "xterm": "4.18.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c74c3df..c2e8147 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,10 +6,10 @@ specifiers: '@sveltejs/pancake': ^0.0.18 katex: 0.15.2 luxon: 2.3.1 - mdast-util-gfm-table: ^1.0.1 + mdast-util-gfm-table: ^1.0.4 mdsvex: 0.10.5 - micromark: ^3.0.5 - micromark-extension-gfm-table: ^1.0.3 + micromark: ^3.0.10 + micromark-extension-gfm-table: ^1.0.5 rehype-autolink-headings: 6.1.1 rehype-katex-svelte: 1.0.3 rehype-slug: 5.0.1 @@ -20,9 +20,9 @@ specifiers: remark-twemoji: 0.1.1 svelte: 3.46.4 twemoji: 13.1.0 - unified: ^10.1.0 + unified: ^10.1.2 vite: ^3.0.9 - vite-plugin-windicss: ^1.8.6 + vite-plugin-windicss: ^1.8.7 xterm: 4.18.0 dependencies: diff --git a/src/routes/posts/rss.xml/+server.js b/src/routes/posts/rss.xml/+server.js index c27796c..81eb6be 100644 --- a/src/routes/posts/rss.xml/+server.js +++ b/src/routes/posts/rss.xml/+server.js @@ -1,14 +1,14 @@ /** * @type {import("@sveltejs/kit").RequestHandler} */ -export async function get(req) { - const allPostFiles = import.meta.glob('../posts/**/*.md'); +export async function GET(req) { + const allPostFiles = import.meta.glob('../**/*.md'); const allPosts = await Promise.all( Object.entries(allPostFiles).map(async ([path, resolver]) => { const { metadata } = await resolver(); let postPath = path.slice(2, -3); - if(postPath.endsWith('/index')) postPath = postPath.slice(0, -6); + if(postPath.endsWith('/+page')) postPath = postPath.slice(0, -6); return { ...metadata, path: postPath, @@ -20,8 +20,7 @@ export async function get(req) { return new Date(b.date) - new Date(a.date) }); - return { - body: ` + return new Response(` Blog - Daniel Bulant @@ -35,12 +34,15 @@ export async function get(req) { ${t.title} ${t.description} - https://danbulant.eu${t.path} + https://danbulant.eu/posts${t.path} ${new Date(t.date).toUTCString()} ${t.path} `).join("\n")} -` - }; +`, { + headers: { + 'Content-Type': 'application/rss+xml' + }, +}); } \ No newline at end of file diff --git a/svelte.config.js b/svelte.config.js index 476541a..34100d5 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -13,7 +13,10 @@ const config = { kit: { adapter: adapter({ precompress: true - }) + }), + prerender: { + default: true + } }, extensions: ['.svelte', '.md'],