mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-29 23:16:51 +00:00
Code🤣
This commit is contained in:
30
lib/rss.js
Normal file
30
lib/rss.js
Normal file
@@ -0,0 +1,30 @@
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user