Files
FastGPT/document/update-index.mjs
Archer 4838a2c9fd remove old doc (#5305)
* auto update index

* update index

* remove old doc
2025-07-24 10:39:41 +08:00

29 lines
782 B
JavaScript

import { algoliasearch } from 'algoliasearch';
import { sync } from 'fumadocs-core/search/algolia';
import * as fs from 'node:fs';
async function main() {
const content = fs.readFileSync('.next/server/app/static.json.body');
// now you can pass it to `sync`
/** @type {import('fumadocs-core/search/algolia').DocumentRecord[]} **/
const records = JSON.parse(content.toString());
if (!process.env.NEXT_PUBLIC_SEARCH_APPID || !process.env.SEARCH_APPWRITEKEY) {
console.log('NEXT_PUBLIC_SEARCH_APPID or SEARCH_APPWRITEKEY is not set');
return;
}
const client = algoliasearch(
process.env.NEXT_PUBLIC_SEARCH_APPID || '',
process.env.SEARCH_APPWRITEKEY || ''
);
void sync(client, {
indexName: 'document',
documents: records
});
}
main();