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

docs: update ContentRenderer custom components #2433

Merged
merged 2 commits into from
Nov 22, 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
18 changes: 17 additions & 1 deletion docs/content/4.components/2.content-renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,28 @@ const { data } = await useAsyncData('page-data', () => queryContent('/hello').fi
::callout{type="info"}
Note that when you use default slot and `<ContentRendererMarkdown>` in your template you need to pass `components` to `<ContentRendererMarkdown>`.

```html [components/CustomParagraph.vue]
<template>
<div>
<ContentSlot :use="$slots.default" unwrap="p" />
</div>
</template>
```

```md [content/index.md]
::custom-p
this is my custom paragraph
::
```

```html [pages/[...slug\\].vue]
<script setup lang="ts">
import { CustomParagraph } from '#components';

const { data } = await useAsyncData('page-data', () => queryContent('/hello').findOne())

const components = {
p: 'CustomParagraph'
'custom-p': CustomParagraph
}
</script>

Expand Down