mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-17 15:09:31 +00:00
Add facebook Open Graph Url and image. Fix PATH env conflict with Vercel environment
This commit is contained in:
37
lib/rss.js
37
lib/rss.js
@@ -1,7 +1,13 @@
|
||||
import { Feed } from 'feed'
|
||||
import BLOG from '@/blog.config'
|
||||
import ReactDOMServer from 'react-dom/server'
|
||||
import { NotionRenderer, Equation, Code, Collection, CollectionRow } from 'react-notion-x'
|
||||
import {
|
||||
NotionRenderer,
|
||||
Equation,
|
||||
Code,
|
||||
Collection,
|
||||
CollectionRow
|
||||
} from 'react-notion-x'
|
||||
import { getPostBlocks } from './notion'
|
||||
|
||||
const mapPageUrl = id => 'https://www.notion.so/' + id.replace(/-/g, '')
|
||||
@@ -13,28 +19,31 @@ const createFeedContent = async post => {
|
||||
}
|
||||
const blockMap = await getPostBlocks(post.id, 'rss-content')
|
||||
if (blockMap) {
|
||||
const content = ReactDOMServer.renderToString(<NotionRenderer
|
||||
recordMap={blockMap}
|
||||
components={{
|
||||
equation: Equation,
|
||||
code: Code,
|
||||
collection: Collection,
|
||||
collectionRow: CollectionRow
|
||||
}}
|
||||
mapPageUrl={mapPageUrl}
|
||||
/>)
|
||||
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
|
||||
const content = ReactDOMServer.renderToString(
|
||||
<NotionRenderer
|
||||
recordMap={blockMap}
|
||||
components={{
|
||||
equation: Equation,
|
||||
code: Code,
|
||||
collection: Collection,
|
||||
collectionRow: CollectionRow
|
||||
}}
|
||||
mapPageUrl={mapPageUrl}
|
||||
/>
|
||||
)
|
||||
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
|
||||
return content.replace(regexExp, '')
|
||||
}
|
||||
return post.summary
|
||||
}
|
||||
|
||||
export async function generateRss (posts) {
|
||||
export async function generateRss(posts) {
|
||||
const year = new Date().getFullYear()
|
||||
const feed = new Feed({
|
||||
title: BLOG.TITLE,
|
||||
description: BLOG.DESCRIPTION,
|
||||
link: `${BLOG.LINK}/${BLOG.PATH}`,
|
||||
link: `${BLOG.LINK}/${BLOG.SUB_PATH}`,
|
||||
language: BLOG.LANG,
|
||||
favicon: `${BLOG.LINK}/favicon.png`,
|
||||
copyright: `All rights reserved ${year}, ${BLOG.AUTHOR}`,
|
||||
|
||||
Reference in New Issue
Block a user