mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-09 20:27:44 +00:00
docs: add orama search support (#4366)
This commit is contained in:
30
docs/scripts/sync-orama.ts
Normal file
30
docs/scripts/sync-orama.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { sync, type OramaDocument } from "fumadocs-core/search/orama-cloud";
|
||||
import * as fs from "node:fs/promises";
|
||||
import { CloudManager } from "@oramacloud/client";
|
||||
import * as process from "node:process";
|
||||
import "dotenv/config";
|
||||
|
||||
const filePath = ".next/server/app/static.json.body";
|
||||
|
||||
async function main() {
|
||||
const apiKey = process.env.ORAMA_PRIVATE_API_KEY;
|
||||
|
||||
if (!apiKey) {
|
||||
console.log("no api key for Orama found, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
const content = await fs.readFile(filePath);
|
||||
const records = JSON.parse(content.toString()) as OramaDocument[];
|
||||
const manager = new CloudManager({ api_key: apiKey });
|
||||
|
||||
await sync(manager, {
|
||||
index: process.env.ORAMA_INDEX_ID!,
|
||||
documents: records,
|
||||
autoDeploy: true,
|
||||
});
|
||||
|
||||
console.log(`search updated: ${records.length} records`);
|
||||
}
|
||||
|
||||
void main();
|
||||
Reference in New Issue
Block a user