diff --git a/pages/about.js b/pages/about.js
index 0ccfeae3..eb97dcbb 100644
--- a/pages/about.js
+++ b/pages/about.js
@@ -7,7 +7,6 @@ import {
} from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import Custom404 from '@/pages/404'
-import { getPageTableOfContents } from 'notion-utils'
import 'prismjs'
import 'prismjs/components/prism-bash'
import 'prismjs/components/prism-javascript'
@@ -21,7 +20,7 @@ import React from 'react'
* @param {*} param0
* @returns
*/
-const About = ({ post, blockMap, tags, prev, next, postCount, categories }) => {
+const About = ({ post, tags, prev, next, postCount, categories }) => {
if (!post) {
return
}
@@ -42,7 +41,7 @@ const About = ({ post, blockMap, tags, prev, next, postCount, categories }) => {
postCount={postCount}
categories={categories}
>
-
+
)
}
@@ -56,20 +55,14 @@ export async function getStaticProps () {
return { props: {}, revalidate: 1 }
}
- const blockMap = await getPostBlocks(post.id, 'slug')
- post.toc = []
- if (blockMap) {
- post.blockMap = blockMap
- post.content = Object.keys(blockMap.block)
- post.toc = getPageTableOfContents(post, blockMap)
- }
+ post.blockMap = await getPostBlocks(post.id, 'slug')
const index = allPosts.indexOf(post)
const prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0]
const next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0]
return {
- props: { post, blockMap, tags, prev, next, categories, postCount, latestPosts },
+ props: { post, tags, prev, next, categories, postCount, latestPosts },
revalidate: 1
}
}
diff --git a/pages/article/[slug].js b/pages/article/[slug].js
index 6ca1254d..42fc4ae7 100644
--- a/pages/article/[slug].js
+++ b/pages/article/[slug].js
@@ -37,6 +37,8 @@ const Slug = ({
const drawerRight = useRef(null)
const targetRef = typeof window !== 'undefined' ? document.getElementById('container') : null
+ post.content = Object.keys(post?.blockMap?.block)
+ post.toc = getPageTableOfContents(post, post.blockMap)
const floatSlot = post?.toc?.length > 1 ?
{ drawerRight?.current?.handleSwitchVisible() }} />
: null
return (
@@ -95,13 +97,7 @@ export async function getStaticProps ({ params: { slug } }) {
return { props: {}, revalidate: 1 }
}
- const blockMap = await getPostBlocks(post.id, 'slug')
- if (blockMap) {
- post.blockMap = blockMap
- post.content = Object.keys(blockMap.block)
- post.toc = getPageTableOfContents(post, blockMap)
- delete post.content
- }
+ post.blockMap = await getPostBlocks(post.id, 'slug')
// 上一篇、下一篇文章关联
const index = allPosts.indexOf(post)