Algolia搜索

This commit is contained in:
tangly1024.com
2023-07-24 17:51:51 +08:00
parent df42d7136d
commit cc59e5cf92
6 changed files with 149 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ import { generateRobotsTxt } from '@/lib/robots.txt'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
import { generateAlgoliaSearch } from '@/lib/algolia'
/**
* 首页布局
@@ -62,6 +63,11 @@ export async function getStaticProps() {
generateRss(props?.latestPosts || [])
}
// 生成全文索引 - 仅在 yarn build 时执行 && process.env.npm_lifecycle_event === 'build'
if (BLOG.ALGOLIA_APP_ID && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA)) {
generateAlgoliaSearch({ allPages: props.allPages })
}
delete props.allPages
return {