Files
plainleaf/plugs/index/document.ts
T
2026-01-20 13:48:15 +01:00

13 lines
555 B
TypeScript

import { index, space, system } from "@silverbulletmd/silverbullet/syscalls";
import type { DocumentMeta } from "../../plug-api/types/index.ts";
// Note: clearFileIndex is not called but since this is the only document:index listener, this should be fine (famous last words)
export async function indexDocument(name: string) {
if (await system.getMode() === "ro") {
return;
}
// console.log("Indexing document", name);
const fileMeta = await space.getDocumentMeta(name);
await index.indexObjects<DocumentMeta>(fileMeta.name, [fileMeta]);
}