Skip to content

docs: using markdown in component slots (docs #2401) #2402

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions packages/docs/docs/guide/using-vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,42 @@ Inside any Markdown file you can then directly use the components (names are inf
Make sure a custom component’s name either contains a hyphen or is in PascalCase. Otherwise it will be treated as an inline element and wrapped inside a `<p>` tag, which will lead to hydration mismatch because `<p>` does not allow block elements to be placed inside it.
:::

### Using Markdown Inside Component Slots

You can write Markdown inside HTML elements by leaving an empty line before and after the Markdown content. This feature allows you to use Markdown inside components with [slots](https://vuejs.org/v2/guide/components-slots.html).

``` md
<ComponentWithSlot>

## This Markdown

- will be compiled
- to correct HTML
- then rendered in a `<slot>` inside ComponentWithSlot

</ComponentWithSlot>
```

You can use Markdown in multiple [named slots](https://vuejs.org/v2/guide/components-slots.html#Named-Slots), with empty lines before and after each part of your Markdown content, for eample:

``` md
<ComponentWithSlots>
<template v-slot:header>

### This Content
Will go in a slot named "header"

</template>

> This Markdown content will go in the *default* slot

</ComponentWithSlots>
```

::: warning
You must specify named slots using `v-slot:`, not the `#` shorthand.
:::

### Using Components In Headers

You can use Vue components in the headers, but note the difference between the following two ways:
Expand Down