mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
fix algolia
This commit is contained in:
@@ -6,7 +6,7 @@ import algoliasearch from 'algoliasearch'
|
||||
* 生成全文索引
|
||||
* @param {*} allPages
|
||||
*/
|
||||
const generateAlgoliaSearch = async({ allPages, force = false }) => {
|
||||
const generateAlgoliaSearch = async ({ allPages, force = false }) => {
|
||||
allPages?.forEach(p => {
|
||||
// 判断这篇文章是否需要重新创建索引
|
||||
if (p && !p.password) {
|
||||
@@ -19,7 +19,7 @@ const generateAlgoliaSearch = async({ allPages, force = false }) => {
|
||||
* 上传数据
|
||||
* 根据上次修改文章日期和上次更新索引数据判断是否需要更新algolia索引
|
||||
*/
|
||||
const uploadDataToAlgolia = async(post) => {
|
||||
const uploadDataToAlgolia = async post => {
|
||||
// Connect and authenticate with your Algolia app
|
||||
const client = algoliasearch(BLOG.ALGOLIA_APP_ID, BLOG.ALGOLIA_ADMIN_APP_KEY)
|
||||
|
||||
@@ -61,14 +61,18 @@ const uploadDataToAlgolia = async(post) => {
|
||||
summary: post.summary,
|
||||
lastEditedDate: post.lastEditedDate, // 更新文章时间
|
||||
lastIndexDate: new Date(), // 更新索引时间
|
||||
content: truncate(getPageContentText(post, post.blockMap), 9000) // 索引9000个字节,因为api限制总请求内容上限1万个字节
|
||||
content: truncate(getPageContentText(post, post.blockMap), 8192) // 索引8192个字符,API限制总请求内容上限1万个字节
|
||||
}
|
||||
// console.log('更新Algolia索引', record)
|
||||
index.saveObject(record).wait().then(r => {
|
||||
console.log('Algolia索引更新', r)
|
||||
}).catch(err => {
|
||||
console.log('Algolia异常', err)
|
||||
})
|
||||
index
|
||||
.saveObject(record)
|
||||
.wait()
|
||||
.then(r => {
|
||||
console.log('Algolia索引更新', r)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('Algolia异常', err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user