From 0baafe474ee258f483588e15e14a6f7d1fc2f451 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 17 Mar 2022 10:08:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?rss=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/rss.js | 1 + pages/feed.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rss.js b/lib/rss.js index d6cbaf4a..a3adba33 100644 --- a/lib/rss.js +++ b/lib/rss.js @@ -3,6 +3,7 @@ import BLOG from '@/blog.config' import ReactDOMServer from 'react-dom/server' import { NotionRenderer, Equation, Code, Collection, CollectionRow } from 'react-notion-x' import { getPostBlocks } from './notion' +import { useRouter } from 'next/router' const mapPageUrl = id => 'https://www.notion.so/' + id.replace(/-/g, '') diff --git a/pages/feed.js b/pages/feed.js index e7499181..ccfe5ff4 100644 --- a/pages/feed.js +++ b/pages/feed.js @@ -3,8 +3,9 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' export async function getServerSideProps ({ res }) { res.setHeader('Content-Type', 'text/xml') - const globalNotionData = await getGlobalNotionData({ from: 'rss' }) - const xmlFeed = await generateRss(globalNotionData?.allPosts?.slice(0, 10) || []) + // 获取最新文章 + const globalNotionData = await getGlobalNotionData({ from: 'rss', latestPostCount: 5 }) + const xmlFeed = await generateRss(globalNotionData?.latestPosts || []) res.write(xmlFeed) res.end() return { From 3210422d952c92f0a3865781b2e520f9cc8dfaa5 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 17 Mar 2022 10:10:36 +0800 Subject: [PATCH 2/2] build --- lib/rss.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rss.js b/lib/rss.js index a3adba33..d6cbaf4a 100644 --- a/lib/rss.js +++ b/lib/rss.js @@ -3,7 +3,6 @@ import BLOG from '@/blog.config' import ReactDOMServer from 'react-dom/server' import { NotionRenderer, Equation, Code, Collection, CollectionRow } from 'react-notion-x' import { getPostBlocks } from './notion' -import { useRouter } from 'next/router' const mapPageUrl = id => 'https://www.notion.so/' + id.replace(/-/g, '')