Compare commits

...

2 Commits

Author SHA1 Message Date
21fb068901 Add the route handler for the XML feed. 2024-10-22 21:07:50 -04:00
ab5a83202e Add the site config type 2024-10-22 20:50:47 -04:00
4 changed files with 33 additions and 8 deletions

12
src/handlers/feed.ts Normal file
View File

@ -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;

View File

@ -1,3 +1,6 @@
/**
* SiteMeta is often used for the `<meta />` tags in the document header
*/
export type SiteMeta = { export type SiteMeta = {
description?: string, description?: string,
tags?: string[], tags?: string[],

View File

@ -1,10 +1,24 @@
import TOML from 'smol-toml'; import TOML from 'smol-toml';
import { CONFIG_PATH } from '@blog/config'; import { CONFIG_PATH } from '@blog/config';
export async function getSiteConfig() { export type SiteConfig = {
title: string;
owner: {
name: string;
email: string;
};
site: {
description: string;
url: string;
repo: string;
language: string;
copyright: string;
}
}
export async function getSiteConfig(): Promise<SiteConfig> {
const siteConfig = CONFIG_PATH + '/site.toml'; const siteConfig = CONFIG_PATH + '/site.toml';
const file = Bun.file(siteConfig); const file = Bun.file(siteConfig);
const data = await file.text(); const data = await file.text();
return TOML.parse(data) as SiteConfig;
return TOML.parse(data);
} }

View File

@ -1,14 +1,10 @@
// generate the feed
//
import { Feed, FeedOptions } from 'feed'; import { Feed, FeedOptions } from 'feed';
import { getSiteConfig } from '@blog/services/config';
export async function feedFactory(): Feed { export async function feedFactory(): Feed {
} }
export async function generateFeed(posts: PostService, feed: Feed): Feed { export async function generateFeed(posts: PostService, feed: Feed): Feed {
const feed = new Feed({});
return feed;
} }