More robustness on lack of space config

lua
Zef Hemel 2024-09-09 18:35:44 +02:00
parent 8348c473e3
commit 409b0df328
2 changed files with 3 additions and 3 deletions

View File

@ -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 {

View File

@ -22,7 +22,7 @@ export async function lintYAML({ tree }: LintEvent): Promise<LintDiagnostic[]> {
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<LintDiagnostic[]> {
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)
) {