From 21fb068901640da6b06bc746caa7002af07764a0 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Tue, 22 Oct 2024 21:07:50 -0400 Subject: [PATCH] Add the route handler for the XML feed. --- src/handlers/feed.ts | 12 ++++++++++++ src/models/SiteMeta.ts | 3 +++ src/services/feed-generator.ts | 6 +----- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 src/handlers/feed.ts diff --git a/src/handlers/feed.ts b/src/handlers/feed.ts new file mode 100644 index 0000000..aaa9295 --- /dev/null +++ b/src/handlers/feed.ts @@ -0,0 +1,12 @@ +import { Hono, Context } from 'hono'; +import { Feed } from 'feed'; + +const feed = new Hono<{ Variables: { feed: Feed }}>(); + +export async function getFeedFile(c: Context) { + c.header('content-type', 'text/xml'); + c.body(""); +} + +feed.get('/rss.xml', getFeedFile); +export default feed; diff --git a/src/models/SiteMeta.ts b/src/models/SiteMeta.ts index 451c9db..00a8d76 100644 --- a/src/models/SiteMeta.ts +++ b/src/models/SiteMeta.ts @@ -1,3 +1,6 @@ +/** + * SiteMeta is often used for the `` tags in the document header + */ export type SiteMeta = { description?: string, tags?: string[], diff --git a/src/services/feed-generator.ts b/src/services/feed-generator.ts index 47d0493..beb90c4 100644 --- a/src/services/feed-generator.ts +++ b/src/services/feed-generator.ts @@ -1,14 +1,10 @@ -// generate the feed -// - import { Feed, FeedOptions } from 'feed'; +import { getSiteConfig } from '@blog/services/config'; export async function feedFactory(): Feed { } export async function generateFeed(posts: PostService, feed: Feed): Feed { - const feed = new Feed({}); - return feed; }