mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
algolia 调整索引
This commit is contained in:
@@ -4,6 +4,7 @@ import { getGlobalData } from '@/lib/notion/getNotionData'
|
||||
import { idToUuid } from 'notion-utils'
|
||||
import { getNotion } from '@/lib/notion/getNotion'
|
||||
import Slug, { getRecommendPost } from '.'
|
||||
import { uploadDataToAlgolia } from '@/lib/algolia'
|
||||
|
||||
/**
|
||||
* 根据notion的slug访问页面
|
||||
@@ -63,6 +64,10 @@ export async function getStaticProps({ params: { prefix, slug } }) {
|
||||
if (!props?.posts?.blockMap) {
|
||||
props.post.blockMap = await getPostBlocks(props.post.id, from)
|
||||
}
|
||||
// 生成全文索引
|
||||
if (BLOG.ALGOLIA_APP_ID && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA) && process.env.npm_lifecycle_event === 'build') {
|
||||
uploadDataToAlgolia(props?.post)
|
||||
}
|
||||
|
||||
// 推荐关联文章处理
|
||||
const allPosts = props.allPages.filter(page => page.type === 'Post' && page.status === 'Published')
|
||||
|
||||
@@ -129,7 +129,8 @@ export async function getStaticProps({ params: { prefix } }) {
|
||||
props.post.blockMap = await getPostBlocks(props.post.id, from)
|
||||
}
|
||||
|
||||
if (BLOG.ALGOLIA_APP_ID && BLOG.ALGOLIA_APP_KEY) {
|
||||
// 生成全文索引
|
||||
if (BLOG.ALGOLIA_APP_ID && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA) && process.env.npm_lifecycle_event === 'build') {
|
||||
uploadDataToAlgolia(props?.post)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user