修复部分NOTION_CONFIG读取问题

This commit is contained in:
tangly1024.com
2024-05-15 14:55:14 +08:00
parent 70e53649b3
commit 517a967640
44 changed files with 911 additions and 565 deletions

View File

@@ -1,9 +1,9 @@
import BLOG from '@/blog.config'
import NotionPage from '@/components/NotionPage'
import { getPostBlocks } from '@/lib/db/getSiteData'
import { Feed } from 'feed'
import fs from 'fs'
import ReactDOMServer from 'react-dom/server'
import { siteConfig } from './config'
/**
* 生成RSS内容
@@ -25,30 +25,33 @@ const createFeedContent = async post => {
}
}
export async function generateRss(NOTION_CONFIG, posts) {
const link = siteConfig('LINK', '', NOTION_CONFIG)
const author = siteConfig('AUTHOR', '', NOTION_CONFIG)
const lang = siteConfig('LANG', '', NOTION_CONFIG)
const subPath = siteConfig('SUB_PATH', '', NOTION_CONFIG)
export async function generateRss(props) {
const { NOTION_CONFIG, siteInfo, latestPosts } = props
const TITLE = siteInfo?.title
const DESCRIPTION = siteInfo?.description
const LINK = siteInfo?.link
const AUTHOR = NOTION_CONFIG?.AUTHOR || BLOG.AUTHOR
const LANG = NOTION_CONFIG?.LANG || BLOG.LANG
const SUB_PATH = NOTION_CONFIG?.SUB_PATH || BLOG.SUB_PATH
const CONTACT_EMAIL = NOTION_CONFIG?.CONTACT_EMAIL || BLOG.CONTACT_EMAIL
const year = new Date().getFullYear()
const feed = new Feed({
title: siteConfig('TITLE', '', NOTION_CONFIG),
description: siteConfig('DESCRIPTION', '', NOTION_CONFIG),
link: `${link}/${subPath}`,
language: lang,
favicon: `${link}/favicon.png`,
copyright: `All rights reserved ${year}, ${author}`,
title: TITLE,
description: DESCRIPTION,
link: `${LINK}/${SUB_PATH}`,
language: LANG,
favicon: `${LINK}/favicon.png`,
copyright: `All rights reserved ${year}, ${AUTHOR}`,
author: {
name: author,
email: siteConfig('CONTACT_EMAIL', '', NOTION_CONFIG),
link: link
name: AUTHOR,
email: CONTACT_EMAIL,
link: LINK
}
})
for (const post of posts) {
for (const post of latestPosts) {
feed.addItem({
title: post.title,
link: `${link}/${post.slug}`,
link: `${LINK}/${post.slug}`,
description: post.summary,
content: await createFeedContent(post),
date: new Date(post?.publishDay)