diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index aac3b9f5f1e..85dd0c7aa2e 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -12,6 +12,7 @@ import { getConfigMapFromConfigPage } from '@/lib/notion/getNotionConfig' export { getAllTags } from '../notion/getAllTags' export { getPostBlocks } from '../notion/getPostBlocks' +export { getPost } from '../notion/getNotionPost' /** * 获取博客数据; 基于Notion实现 diff --git a/lib/notion/getNotion.js b/lib/notion/getNotionPost.js similarity index 96% rename from lib/notion/getNotion.js rename to lib/notion/getNotionPost.js index 20208158b5f..beb3bf5649f 100644 --- a/lib/notion/getNotion.js +++ b/lib/notion/getNotionPost.js @@ -9,7 +9,7 @@ import { defaultMapImageUrl } from 'react-notion-x' * @param {*} pageId * @returns */ -export async function getNotion(pageId) { +export async function getPost(pageId) { const blockMap = await getPostBlocks(pageId, 'slug') if (!blockMap) { return null diff --git a/pages/[prefix]/[slug]/[...suffix].js b/pages/[prefix]/[slug]/[...suffix].js index 8983f4193a5..d34b296af19 100644 --- a/pages/[prefix]/[slug]/[...suffix].js +++ b/pages/[prefix]/[slug]/[...suffix].js @@ -1,7 +1,6 @@ import BLOG from '@/blog.config' -import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData' +import { getGlobalData, getPostBlocks, getPost } from '@/lib/db/getSiteData' import { idToUuid } from 'notion-utils' -import { getNotion } from '@/lib/notion/getNotion' import Slug, { getRecommendPost } from '..' import { uploadDataToAlgolia } from '@/lib/plugins/algolia' import { checkContainHttp } from '@/lib/utils' @@ -61,7 +60,7 @@ export async function getStaticProps({ params: { prefix, slug, suffix } }) { if (!props?.post) { const pageId = fullSlug.slice(-1)[0] if (pageId.length >= 32) { - const post = await getNotion(pageId) + const post = await getPost(pageId) props.post = post } } diff --git a/pages/[prefix]/[slug]/index.js b/pages/[prefix]/[slug]/index.js index 3f6b81fe26f..1cbfd0d9ba0 100644 --- a/pages/[prefix]/[slug]/index.js +++ b/pages/[prefix]/[slug]/index.js @@ -1,7 +1,6 @@ import BLOG from '@/blog.config' -import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData' +import { getGlobalData, getPostBlocks, getPost } from '@/lib/db/getSiteData' import { idToUuid } from 'notion-utils' -import { getNotion } from '@/lib/notion/getNotion' import Slug, { getRecommendPost } from '..' import { uploadDataToAlgolia } from '@/lib/plugins/algolia' import { checkContainHttp } from '@/lib/utils' @@ -52,7 +51,7 @@ export async function getStaticProps({ params: { prefix, slug } }) { if (!props?.post) { const pageId = slug.slice(-1)[0] if (pageId.length >= 32) { - const post = await getNotion(pageId) + const post = await getPost(pageId) props.post = post } } diff --git a/pages/[prefix]/index.js b/pages/[prefix]/index.js index 5c56f7e0cca..5fc25e18d9f 100644 --- a/pages/[prefix]/index.js +++ b/pages/[prefix]/index.js @@ -1,9 +1,8 @@ import BLOG from '@/blog.config' -import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData' +import { getGlobalData, getPostBlocks, getPost } from '@/lib/db/getSiteData' import { useEffect, useState } from 'react' import { idToUuid } from 'notion-utils' import { useRouter } from 'next/router' -import { getNotion } from '@/lib/notion/getNotion' import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents' import { getLayoutByTheme } from '@/themes/theme' import md5 from 'js-md5' @@ -92,7 +91,7 @@ export async function getStaticProps({ params: { prefix } }) { if (!props?.post) { const pageId = prefix if (pageId.length >= 32) { - const post = await getNotion(pageId) + const post = await getPost(pageId) props.post = post } }