From 409b0df3284504ce2d49949a6e65622f08d063c7 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Mon, 9 Sep 2024 18:35:44 +0200 Subject: [PATCH] More robustness on lack of space config --- common/syscalls/system.ts | 2 +- plugs/index/lint.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/syscalls/system.ts b/common/syscalls/system.ts index a128c2b3..d6bba160 100644 --- a/common/syscalls/system.ts +++ b/common/syscalls/system.ts @@ -141,7 +141,7 @@ export function systemSyscalls( return commonSystem.applyAttributeExtractors(tags, text, tree); }, "system.getSpaceConfig": (_ctx, key?: string): any => { - const config: any = configContainer.config; + const config: any = configContainer.config || {}; if (key) { return config[key]; } else { diff --git a/plugs/index/lint.ts b/plugs/index/lint.ts index b821fcff..2d473f72 100644 --- a/plugs/index/lint.ts +++ b/plugs/index/lint.ts @@ -22,7 +22,7 @@ export async function lintYAML({ tree }: LintEvent): Promise { const diagnostics: LintDiagnostic[] = []; const frontmatter = await extractFrontmatter(tree); const tags = ["page", ...frontmatter.tags || []]; - const schemaConfig = await system.getSpaceConfig("schema"); + const schemaConfig = await system.getSpaceConfig("schema", {}); await traverseTreeAsync(tree, async (node) => { if (node.type === "FrontMatterCode") { // Query all readOnly attributes for pages with this tag set @@ -110,7 +110,7 @@ export async function lintYAML({ tree }: LintEvent): Promise { let parsed = await YAML.parse(yamlCode); parsed = cleanupJSON(parsed); // If tag schemas are defined, validate them - if (parsed.schema?.tag) { + if (parsed?.schema?.tag) { for ( let [tagName, tagSchema] of Object.entries(parsed.schema.tag) ) {