diff --git a/plug-api/types/event.ts b/plug-api/types/event.ts index e3b1e529..75dc10a1 100644 --- a/plug-api/types/event.ts +++ b/plug-api/types/event.ts @@ -1,9 +1,11 @@ import type { ParseTree } from "@silverbulletmd/silverbullet/lib/tree"; import type { EventSubscriptionDef } from "./manifest.ts"; +import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; export type IndexTreeEvent = { name: string; tree: ParseTree; + meta: PageMeta; text: string; }; diff --git a/plugs/index/index.ts b/plugs/index/index.ts index 9b5219a9..de6d6744 100644 --- a/plugs/index/index.ts +++ b/plugs/index/index.ts @@ -5,7 +5,6 @@ import type { import { extractFrontMatter, type FrontMatter } from "./frontmatter.ts"; import type { ParseTree } from "@silverbulletmd/silverbullet/lib/tree"; import type { IndexTreeEvent } from "@silverbulletmd/silverbullet/type/event"; -import { space } from "@silverbulletmd/silverbullet/syscalls"; import { indexObjects } from "./api.ts"; import { indexPage as pageIndexPage } from "./page.ts"; import { indexData } from "./data.ts"; @@ -38,15 +37,14 @@ const allIndexers: IndexerFunction[] = [ indexTags, ]; -export async function indexPage({ name, tree, text }: IndexTreeEvent) { - const pageMeta = await space.getPageMeta(name); +export async function indexPage({ name, tree, meta, text }: IndexTreeEvent) { const frontmatter = extractFrontMatter(tree); // console.log("Now going to index page", name); // Index the page const index = await Promise.all(allIndexers.map((indexer) => { - return indexer(pageMeta, frontmatter, tree, text); + return indexer(meta, frontmatter, tree, text); })); // console.log("Found these objects", index.flat()); diff --git a/plugs/index/queue.ts b/plugs/index/queue.ts index 25fc7bc3..075d3bcb 100644 --- a/plugs/index/queue.ts +++ b/plugs/index/queue.ts @@ -79,12 +79,13 @@ async function indexFile(path: string) { // Page const name = path.slice(0, -3); // Read and parse the file - const text = await space.readPage(name); + const { text, meta } = await space.readPageWithMeta(name); const tree = await markdown.parseMarkdown(text); // Emit the event which will be picked up by indexers await events.dispatchEvent("page:index", { name, + meta, tree, text, } as IndexTreeEvent);