attachment field can be null (#170584)

This commit is contained in:
Aaron Munger
2023-01-05 10:06:36 -08:00
committed by GitHub
parent e1bb3ec918
commit 0294a28ca0

View File

@@ -22,7 +22,7 @@ export async function activate(ctx: RendererContext<void>) {
md.renderer.rules.image = (tokens: MarkdownItToken[], idx: number, options, env, self) => {
const token = tokens[idx];
const src = token.attrGet('src');
const attachments: Record<string, Record<string, string>> = env.outputItem.metadata.attachments;
const attachments: Record<string, Record<string, string>> | undefined = env.outputItem.metadata?.attachments;
if (attachments && src) {
const imageAttachment = attachments[src.replace('attachment:', '')];
if (imageAttachment) {