fix: do not crash when Markdown has no content (#1702)
This commit is contained in:
parent
c9b33d2b7e
commit
6becdc8cc0
1 changed files with 13 additions and 7 deletions
|
@ -12,21 +12,27 @@ interface InternalProps extends Props {
|
|||
|
||||
let { content, class: className } = Astro.props as InternalProps;
|
||||
let html = null;
|
||||
let htmlContent = '';
|
||||
|
||||
const { privateRenderMarkdownDoNotUse: renderMarkdown } = (Astro as any);
|
||||
|
||||
// If no content prop provided, use the slot.
|
||||
if (!content) {
|
||||
const { privateRenderSlotDoNotUse: renderSlot } = (Astro as any);
|
||||
content = dedent(await renderSlot('default'));
|
||||
content = await renderSlot('default');
|
||||
if (content.trim().length > 0) {
|
||||
content = dedent(content);
|
||||
}
|
||||
}
|
||||
|
||||
const htmlContent = await renderMarkdown(content, {
|
||||
if (content) {
|
||||
htmlContent = await renderMarkdown(content, {
|
||||
mode: 'md',
|
||||
$: {
|
||||
scopedClassName: className
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
html = htmlContent;
|
||||
---
|
||||
|
|
Loading…
Reference in a new issue