Files
NotionNext/lib/rss.js
tangly1024 2d567b309f feature:
网页根据浏览器本地化语言
2021-12-01 12:35:34 +08:00

31 lines
808 B
JavaScript

import { Feed } from 'feed'
import BLOG from '@/blog.config'
export function generateRss (posts) {
const year = new Date().getFullYear()
const feed = new Feed({
title: BLOG.title,
description: BLOG.description,
id: `${BLOG.link}/${BLOG.path}`,
link: `${BLOG.link}/${BLOG.path}`,
language: BLOG.lang,
favicon: `${BLOG.link}/favicon.png`,
copyright: `All rights reserved ${year}, ${BLOG.author}`,
author: {
name: BLOG.author,
email: BLOG.email,
link: BLOG.link
}
})
posts.forEach(post => {
feed.addItem({
title: post.title,
id: `${BLOG.link}/${post.slug}`,
link: `${BLOG.link}/${post.slug}`,
description: post.summary,
date: new Date(post?.date?.start_date || post.createdTime)
})
})
return feed.rss2()
}