From b359d9e0653c71c49794c6f1431da6f69f3926bd Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 15 Nov 2023 13:41:36 +0100 Subject: [PATCH] Don't index templates during full space reindex --- plugs/index/command.ts | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/plugs/index/command.ts b/plugs/index/command.ts index e900c257..820893f6 100644 --- a/plugs/index/command.ts +++ b/plugs/index/command.ts @@ -35,24 +35,34 @@ export async function processIndexQueue(messages: MQMessage[]) { console.log(`Indexing page ${name}`); const text = await space.readPage(name); const parsed = await markdown.parseMarkdown(text); + if (isTemplate(text)) { + console.log("Indexing", name, "as template"); + await events.dispatchEvent("page:indexTemplate", { + name, + tree: parsed, + }); + } else { + await events.dispatchEvent("page:index", { + name, + tree: parsed, + }); + } + } +} + +export async function parseIndexTextRepublish({ name, text }: IndexEvent) { + const parsed = await markdown.parseMarkdown(text); + + if (isTemplate(text)) { + console.log("Indexing", name, "as template"); + await events.dispatchEvent("page:indexTemplate", { + name, + tree: parsed, + }); + } else { await events.dispatchEvent("page:index", { name, tree: parsed, }); } } - -export async function parseIndexTextRepublish({ name, text }: IndexEvent) { - if (isTemplate(text)) { - console.log("Indexing", name, "as template"); - await events.dispatchEvent("page:indexTemplate", { - name, - tree: await markdown.parseMarkdown(text), - }); - } else { - await events.dispatchEvent("page:index", { - name, - tree: await markdown.parseMarkdown(text), - }); - } -}