Work on the feed generator to use the PostService.

This commit is contained in:
Dave Smith-Hayes 2024-11-18 22:44:52 -05:00
parent 4c78f3f83e
commit db0836a499
2 changed files with 37 additions and 0 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -1,4 +1,41 @@
import { Feed, FeedOptions } from 'feed';
import { getSiteConfig } from '@blog/services/config';
import { PostService } from '@blog/services/post-file';
import type { Post } from '@blog/models/post';
const updatedDate = new Date();
export async function getFeed(postService: PostService): Feed {
const config = getSiteConfig();
const feed = new Feed({
title: config.title,
description: config.site.description,
link: config.site.link,
language: config.site.language,
copyright: config.site.copyright,
generator: "dsh feed gen",
updated: updatedDate,
author: {
name: "Dave Smith-Hayes",
email: "me@davesmithhayes.com",
link: "davesmithhayes.com"
}
});
postService.getAllPosts().map((post: Post) => {
feed.addItem({
title: post.meta.title,
id: post.meta.slug,
link: post.meta.slug,
description: post.meta.description,
content: post.html,
author: [
name: config.author,
email: config.email
]
});
});
return feed;
}