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") {