Skip to content

Commit

Permalink
chore: update markdown renderer usages
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Jun 29, 2022
1 parent be028a8 commit 9cbc3a1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/content/4.api/1.components/2.content-renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: 'Takes your component from an AST to a wonderful template.'

The `<ContentRenderer>`{lang=html} component renders a document coming from a query.

It will use `<MarkdownRenderer>`{lang=html} component to render `.md` file types.
It will use `<ContentRendererMarkdown>`{lang=html} component to render `.md` file types.

Other types will currently be passed to default slot via `v-slot="{ data }"` or be rendered inside `<pre />` tag.

Expand Down Expand Up @@ -34,7 +34,7 @@ const { data } = await useAsyncData('page-data', () => queryContent('/hello').fi
<main>
<ContentRenderer :value="data">
<h1>{{ data.title }}</h1>
<MarkdownRenderer :value="data" />
<ContentRendererMarkdown :value="data" />
</ContentRenderer>
</main>
</template>
Expand Down
4 changes: 2 additions & 2 deletions playground/basic/content/1.real-content/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ const { data } = await useAsyncData(`doc-${route.path}`, () => queryContent(rout
</template>
```

### `<MarkdownRenderer>`
### `<ContentRendererMarkdown>`

> This component is used by `<ContentRenderer>` under the hood.
Render a markdown content.

```vue
<template>
<MarkdownRenderer :value="data" />
<ContentRendererMarkdown :value="data" />
</template>
```

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/components/ContentRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default defineComponent({

const { value, excerpt, tag } = ctx

// Use built-in MarkdownRenderer
// Use built-in ContentRendererMarkdown
if (value && value?._type === 'markdown' && value?.body?.children?.length) {
return h(
ContentRendererMarkdown,
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/markdown-parser/utils/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function isTag (vnode: VNode | MarkdownNode, tag: string | symbol): boole
if (vnode.type === tag) {
return true
}
// Vue 3 VNode `type` can be an object (tag is provided by MarkdownRenderer)
// Vue 3 VNode `type` can be an object (tag is provided by ContentRendererMarkdown)
if (typeof vnode.type === 'object' && (vnode.type as any).tag === tag) {
return true
}
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/basic/components/content/Alert.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<Markdown />
</div>
</template>
2 changes: 1 addition & 1 deletion test/fixtures/basic/pages/parse.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<MarkdownRenderer :value="data" />
<ContentRendererMarkdown :value="data" />
</div>
</template>

Expand Down

0 comments on commit 9cbc3a1

Please sign in to comment.