diff --git a/lib/robots.txt.js b/lib/robots.txt.js
index 2592e1ff..ca3d4cc2 100644
--- a/lib/robots.txt.js
+++ b/lib/robots.txt.js
@@ -3,17 +3,22 @@ import fs from 'fs'
import BLOG from '@/blog.config'
export async function generateRobotsTxt() {
- fs.mkdirSync('./public', { recursive: true })
- fs.writeFileSync('./public/robots.txt', `
- # *
- User-agent: *
- Allow: /
-
- # Host
- Host: ${BLOG.LINK}
-
- # Sitemaps
- Sitemap: ${BLOG.LINK}/sitemap.xml
-
- `)
+ const content = `
+ # *
+ User-agent: *
+ Allow: /
+
+ # Host
+ Host: ${BLOG.LINK}
+
+ # Sitemaps
+ Sitemap: ${BLOG.LINK}/sitemap.xml
+
+ `
+ try {
+ fs.writeFileSync('robots.txt', content)
+ fs.writeFileSync('./public/robots.txt', content)
+ } catch (error) {
+ console.warn('无法写入文件', error)
+ }
}
diff --git a/lib/rss.js b/lib/rss.js
index 66723f93..8536854a 100644
--- a/lib/rss.js
+++ b/lib/rss.js
@@ -5,6 +5,26 @@ import ReactDOMServer from 'react-dom/server'
import { getPostBlocks } from './notion'
import NotionPage from '@/components/NotionPage'
+/**
+ * 生成RSS内容
+ * @param {*} post
+ * @returns
+ */
+const createFeedContent = async post => {
+ // 加密的文章内容只返回摘要
+ if (post.password && post.password !== '') {
+ return post.summary
+ }
+ const blockMap = await getPostBlocks(post.id, 'rss-content')
+ if (blockMap) {
+ post.blockMap = blockMap
+ const content = ReactDOMServer.renderToString(