Pre-index SETTINGS on full space reindex

pull/1027/head
Zef Hemel 2024-08-05 09:15:31 +02:00
parent 2b01130afd
commit 1bb096f503
1 changed files with 21 additions and 14 deletions

View File

@ -24,8 +24,12 @@ export async function reindexSpace(noClear = false) {
}
// Load builtins
await system.invokeFunction("index.loadBuiltinsIntoIndex");
// Pre-index SETTINGS page to get useful settings
console.log("Indexing SETTINGS page");
await indexPage("SETTINGS");
const files = await space.listFiles();
console.log("Queing", files.length, "pages to be indexed.");
// Queue all file names to be indexed
await mq.batchSend("indexQueue", files.map((file) => file.name));
@ -49,10 +53,17 @@ export async function processIndexQueue(messages: MQMessage[]) {
console.log(`Indexing file ${name}`);
if (name.endsWith(".md")) {
name = name.slice(0, -3);
await indexPage(name);
} else {
await indexAttachment(name);
}
}
}
async function indexPage(name: string) {
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,
@ -63,10 +74,6 @@ export async function processIndexQueue(messages: MQMessage[]) {
tree: parsed,
});
}
} else {
await indexAttachment(name);
}
}
}
export async function parseIndexTextRepublish({ name, text }: IndexEvent) {