Add the post service to the middleware definition of the feed app, plan out how to get the feed. Cache the results.
This commit is contained in:
parent
e21de55d3f
commit
4c78f3f83e
@ -1,15 +1,19 @@
|
|||||||
import { Hono, Context } from 'hono';
|
import { Hono, Context } from 'hono';
|
||||||
|
import { PostService } from '@blog/services/post-file';
|
||||||
import { Feed } from 'feed';
|
import { Feed } from 'feed';
|
||||||
|
|
||||||
const feed = new Hono();
|
const feed = new Hono<{ Variables: { postService: PostService }}>();
|
||||||
let feedBuffer: string = "";
|
let feedBuffer: string = "";
|
||||||
|
|
||||||
export async function getFeedFile(c: Context) {
|
export async function getFeedFile(c: Context) {
|
||||||
c.header('Content-Type', 'text/xml');
|
c.header('Content-Type', 'text/xml');
|
||||||
|
|
||||||
if (!feedBuffer) {
|
if (!feedBuffer) {
|
||||||
// get the post meta
|
const postService: PostService = c.get('postService');
|
||||||
|
const posts = postService.getPublishedPosts();
|
||||||
|
|
||||||
// get the site meta
|
// get the site meta
|
||||||
|
|
||||||
// create the feed
|
// create the feed
|
||||||
// get the feed data
|
// get the feed data
|
||||||
feedBuffer = "";
|
feedBuffer = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user