Work on the feed generator to use the PostService.
This commit is contained in:
parent
4c78f3f83e
commit
db0836a499
@ -1,4 +1,41 @@
|
|||||||
import { Feed, FeedOptions } from 'feed';
|
import { Feed, FeedOptions } from 'feed';
|
||||||
import { getSiteConfig } from '@blog/services/config';
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user