Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ContentRendererMarkdown): prevent undefined error on component resolve #2021

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 16 additions & 15 deletions src/runtime/components/ContentRendererMarkdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,29 @@ export default defineComponent({
async setup (props) {
const { content: { tags = {} } } = useRuntimeConfig().public

await resolveContentComponents(props.value.body, {
tags: {
...tags,
...toRaw(props.value?._components || {}),
...props.components
}
})
let body = (props.value?.body || props.value) as MarkdownNode
if (props.excerpt && props.value?.excerpt) {
body = props.value.excerpt as MarkdownNode
}
if (body) {
await resolveContentComponents(body, {
tags: {
...tags,
...toRaw(props.value?._components || {}),
...props.components
}
})
}

return { tags }
return { tags, body }
},
render (ctx: any) {
const { tags, tag, value, components } = ctx
const { tags, tag, value, body, components } = ctx

if (!value) {
if (!body) {
return null
}

// Get body from value
let body = (value.body || value) as MarkdownNode
if (ctx.excerpt && value.excerpt) {
body = value.excerpt
}
const meta: ParsedContentMeta = {
...(value as ParsedContentMeta),
tags: {
Expand Down