-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync-index.mjs
More file actions
27 lines (20 loc) · 815 Bytes
/
sync-index.mjs
File metadata and controls
27 lines (20 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { CloudManager } from "@oramacloud/client";
import { sync } from "fumadocs-core/search/orama-cloud";
import * as fs from "node:fs/promises";
export async function updateSearchIndexes() {
const apiKey = process.env.ORAMA_PRIVATE_API_KEY; // private API key
if (!apiKey) {
console.log("no api key for Orama found, skipping");
return;
}
const content = await fs.readFile(".next/server/app/static.json.body");
const toString = content.toString().replace(/\/en\//g, "/");
const records = JSON.parse(toString);
const manager = new CloudManager({ api_key: apiKey });
await sync(manager, {
index: "ux1vl2mzlylu0oak3j8v37xd",
documents: records,
});
console.log(`search updated: ${records.length} records`);
}
void updateSearchIndexes();