mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-31 07:26:43 +00:00
调整RSS方案,节省流量
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
import { generateRss } from '@/lib/rss'
|
||||
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?.latestPosts || [])
|
||||
res.write(xmlFeed)
|
||||
res.end()
|
||||
return {
|
||||
props: {}
|
||||
}
|
||||
}
|
||||
|
||||
const feed = () => null
|
||||
export default feed
|
||||
@@ -3,6 +3,7 @@ import { getPostBlocks } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import * as ThemeMap from '@/themes'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { generateRss } from '@/lib/rss'
|
||||
const Index = props => {
|
||||
const { theme } = useGlobal()
|
||||
const ThemeComponents = ThemeMap[theme]
|
||||
@@ -12,8 +13,10 @@ const Index = props => {
|
||||
export async function getStaticProps() {
|
||||
const from = 'index'
|
||||
const props = await getGlobalNotionData({ from })
|
||||
|
||||
const { siteInfo } = props
|
||||
props.posts = props.allPages.filter(page => page.type === 'Post' && page.status === 'Published')
|
||||
|
||||
delete props.allPages
|
||||
const meta = {
|
||||
title: `${siteInfo?.title} | ${siteInfo?.description}`,
|
||||
@@ -40,6 +43,9 @@ export async function getStaticProps() {
|
||||
}
|
||||
}
|
||||
|
||||
// 异步生成Feed订阅
|
||||
generateRss(props?.latestPosts || [])
|
||||
|
||||
return {
|
||||
props: {
|
||||
meta,
|
||||
|
||||
Reference in New Issue
Block a user