mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
31 lines
807 B
JavaScript
31 lines
807 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()
|
|
}
|