mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
frame-work lib/db
This commit is contained in:
@@ -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实现
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user