Skip to content

Commit 0316bc9

Browse files
author
Felix Zieger
committed
fix: crash upon encountering link_preview
1 parent 15cece7 commit 0316bc9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/RichTextRenderer.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,17 @@ export class RichTextRenderer {
6060
}
6161
// todo: support for mentions is probably useful, for cross-page links?
6262
case "text":
63-
const text = this.wrap(mod, rt.text.content);
64-
return rt.text.link
65-
? this.linkRenderer.renderUrlLink(text, rt.text.link.url)
66-
: text;
63+
// TODO move to above switch statement after upgrading notion client to newest version
64+
// switch(rt.mention.type) case: "link_preview" not supported, because types are outdated in @notionhq/client v0.3.x
65+
if (rt.text === undefined && rt.href !== undefined) {
66+
const link_text = this.wrap(mod, rt.plain_text)
67+
return this.linkRenderer.renderUrlLink(link_text, rt.href)
68+
} else {
69+
const text = this.wrap(mod, rt.text.content);
70+
return rt.text.link
71+
? this.linkRenderer.renderUrlLink(text, rt.text.link.url)
72+
: text;
73+
}
6774
}
6875
}
6976

0 commit comments

Comments
 (0)