diff --git a/bun.lockb b/bun.lockb index 9f74060..60574a5 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/src/services/feed-generator.ts b/src/services/feed-generator.ts index 532e217..989caa6 100644 --- a/src/services/feed-generator.ts +++ b/src/services/feed-generator.ts @@ -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; +}