Skip to content

Commit a9d7370

Browse files
authored
fix(kumascript): mention path in render error message (v2) (#8953)
* fix(kumascript): mention path in render error message * fix(kumascript): render without fileInfo.path * fix(blog): add fileInfo.path to render context
1 parent 0896970 commit a9d7370

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

Diff for: build/blog.ts

+9
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ export async function findPostLiveSampleBySlug(
7575
rawBody: body,
7676
metadata: { locale: DEFAULT_LOCALE, ...blogMeta },
7777
isMarkdown: true,
78+
fileInfo: {
79+
path: file,
80+
},
7881
});
7982
return liveSamples.find((page) => page.id.toLowerCase() === id)?.html;
8083
}
@@ -94,6 +97,9 @@ export async function findPostBySlug(
9497
rawBody: body,
9598
metadata: { locale: DEFAULT_LOCALE, ...blogMeta },
9699
isMarkdown: true,
100+
fileInfo: {
101+
path: file,
102+
},
97103
});
98104
return { doc, blogMeta };
99105
}
@@ -177,6 +183,9 @@ export async function buildBlogPosts(options: {
177183
rawBody: body,
178184
metadata: { locale, ...blogMeta },
179185
isMarkdown: true,
186+
fileInfo: {
187+
path: file,
188+
},
180189
};
181190
const { doc: builtDoc, liveSamples } = await buildPost(renderDoc);
182191
const { doc } = {

Diff for: kumascript/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export async function render(
9191
rawHTML,
9292
{
9393
...metadata,
94+
path: fileInfo?.path,
9495
url,
9596
tags: metadata.tags || [],
9697
selective_mode,

Diff for: kumascript/src/templates.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ export default class Templates {
108108
});
109109
return rendered.trim();
110110
} catch (error) {
111-
console.error(`${name} macro failed:`, error);
111+
console.error(
112+
`The ${name} macro in ${
113+
args.env.path ?? args.env.url
114+
} failed to render.`,
115+
error
116+
);
112117
throw error;
113118
}
114119
}

0 commit comments

Comments
 (0)