From 513b9ef44172505d9f7da09b3e25026f12b10628 Mon Sep 17 00:00:00 2001 From: MrMugame <40832361+MrMugame@users.noreply.github.com> Date: Mon, 24 Jun 2024 06:21:57 +0200 Subject: [PATCH] Recreate file list on every call of pageExists() (#900) --- common/query_functions.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/query_functions.ts b/common/query_functions.ts index 37c6b12e..faf5fd16 100644 --- a/common/query_functions.ts +++ b/common/query_functions.ts @@ -11,11 +11,6 @@ export function buildQueryFunctions( system: System, ): FunctionMap { const pageCache = new LimitedMap(10); - allKnownFiles = new Set( - [...allKnownFiles].flatMap((file) => - (file.endsWith(".md")) ? [file.slice(0, -3)] : [] - ), - ); return { ...builtinFunctions, @@ -28,7 +23,14 @@ export function buildQueryFunctions( // Let's assume federated pages exist, and ignore template variable ones return true; } - return allKnownFiles.has(name); + + const flattendFiles = new Set( + [...allKnownFiles].flatMap((file) => + (file.endsWith(".md")) ? [file.slice(0, -3)] : [] + ), + ); + + return flattendFiles.has(name); }, async template(template: unknown, obj: unknown) { if (typeof template !== "string") {