mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
将LINK,NEXT_REVALIDATE_SECOND配置提升到NOTION_CONFIG中
This commit is contained in:
@@ -123,7 +123,7 @@ export const redirectUserLang = (lang, pageId) => {
|
||||
getQueryVariable('locale') ||
|
||||
getQueryVariable('lang') ||
|
||||
window?.navigator?.language
|
||||
const siteIds = pageId.split(',')
|
||||
const siteIds = pageId?.split(',') || []
|
||||
|
||||
// 默认是进首页; 如果检测到有一个多语言匹配了用户浏览器,则自动跳转过去
|
||||
for (let index = 0; index < siteIds.length; index++) {
|
||||
|
||||
40
lib/rss.js
40
lib/rss.js
@@ -1,15 +1,16 @@
|
||||
import fs from 'fs'
|
||||
import { Feed } from 'feed'
|
||||
import BLOG from '@/blog.config'
|
||||
import ReactDOMServer from 'react-dom/server'
|
||||
import { getPostBlocks } from '@/lib/db/getSiteData'
|
||||
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内容
|
||||
* @param {*} post
|
||||
* @returns
|
||||
*/
|
||||
* 生成RSS内容
|
||||
* @param {*} post
|
||||
* @returns
|
||||
*/
|
||||
const createFeedContent = async post => {
|
||||
// 加密的文章内容只返回摘要
|
||||
if (post.password && post.password !== '') {
|
||||
@@ -20,30 +21,35 @@ const createFeedContent = async post => {
|
||||
post.blockMap = blockMap
|
||||
const content = ReactDOMServer.renderToString(<NotionPage post={post} />)
|
||||
const regexExp =
|
||||
/<div class="notion-collection-row"><div class="notion-collection-row-body"><div class="notion-collection-row-property"><div class="notion-collection-column-title"><svg.*?class="notion-collection-column-title-icon">.*?<\/svg><div class="notion-collection-column-title-body">.*?<\/div><\/div><div class="notion-collection-row-value">.*?<\/div><\/div><\/div><\/div>/g
|
||||
/<div class="notion-collection-row"><div class="notion-collection-row-body"><div class="notion-collection-row-property"><div class="notion-collection-column-title"><svg.*?class="notion-collection-column-title-icon">.*?<\/svg><div class="notion-collection-column-title-body">.*?<\/div><\/div><div class="notion-collection-row-value">.*?<\/div><\/div><\/div><\/div>/g
|
||||
return content.replace(regexExp, '')
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateRss(posts) {
|
||||
export async function generateRss(NOTION_CONFIG, posts) {
|
||||
const link = siteConfig('LINK', BLOG.LINK, NOTION_CONFIG)
|
||||
const author = siteConfig('AUTHOR', BLOG.AUTHOR, NOTION_CONFIG)
|
||||
const lang = siteConfig('LANG', BLOG.LANG, NOTION_CONFIG)
|
||||
const subPath = siteConfig('SUB_PATH', BLOG.SUB_PATH, NOTION_CONFIG)
|
||||
|
||||
const year = new Date().getFullYear()
|
||||
const feed = new Feed({
|
||||
title: BLOG.TITLE,
|
||||
description: BLOG.DESCRIPTION,
|
||||
link: `${BLOG.LINK}/${BLOG.SUB_PATH}`,
|
||||
language: BLOG.LANG,
|
||||
favicon: `${BLOG.LINK}/favicon.png`,
|
||||
copyright: `All rights reserved ${year}, ${BLOG.AUTHOR}`,
|
||||
link: `${link}/${subPath}`,
|
||||
language: lang,
|
||||
favicon: `${link}/favicon.png`,
|
||||
copyright: `All rights reserved ${year}, ${author}`,
|
||||
author: {
|
||||
name: BLOG.AUTHOR,
|
||||
name: author,
|
||||
email: BLOG.CONTACT_EMAIL,
|
||||
link: BLOG.LINK
|
||||
link: link
|
||||
}
|
||||
})
|
||||
for (const post of posts) {
|
||||
feed.addItem({
|
||||
title: post.title,
|
||||
link: `${BLOG.LINK}/${post.slug}`,
|
||||
link: `${link}/${post.slug}`,
|
||||
description: post.summary,
|
||||
content: await createFeedContent(post),
|
||||
date: new Date(post?.publishDay)
|
||||
|
||||
Reference in New Issue
Block a user