mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-16 23:16:48 +00:00
升级react-notion-x,封装NotionPage
This commit is contained in:
23
lib/rss.js
23
lib/rss.js
@@ -1,16 +1,8 @@
|
||||
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 { getPostBlocks } from './notion'
|
||||
|
||||
const mapPageUrl = id => 'https://www.notion.so/' + id.replace(/-/g, '')
|
||||
import NotionPage from '@/components/NotionPage'
|
||||
|
||||
const createFeedContent = async post => {
|
||||
// 加密的文章内容只返回摘要
|
||||
@@ -19,18 +11,7 @@ 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 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
|
||||
return content.replace(regexExp, '')
|
||||
|
||||
Reference in New Issue
Block a user