You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/4.components/1.slot.md
+9-23Lines changed: 9 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,18 @@
1
1
---
2
-
title: MDCSlot
2
+
title: slot
3
3
description: The fastest way to inject Markdown into your Vue components.
4
4
---
5
5
6
-
::warning
7
-
We recommend using `<slot>` as much as possible an only use `<MDCSlot>` when you need unwrapping which is not covered by MDC defaults.
8
-
::
9
-
10
-
The `<MDCSlot>` is an extension of the [`<slot>`](https://vuejs.org/guide/components/slots.html) component that makes it easier to render and manipulate Markdown content within your Vue components.
11
-
12
-
::note
13
-
This component is part of [`@nuxtjs/mdc`](https://github.com/nuxt-modules/mdc).
14
-
::
6
+
When you write contents and paragraphs inside a component with the MDC syntax, you can use Vue's `<slot>` component to render the content.
15
7
16
8
## Usage
17
9
18
-
This component is a replacement for Vue's `<slot>` component, specifically designed for MDC.
19
-
20
-
Use the `<MDCSlot>` component instead of the native `<slot>` component:
10
+
If you don't want to modify the rendered content, simply use Vue's `<slot>` component.
21
11
22
12
```vue [components/content/Callout.vue]
23
13
<template>
24
14
<div class="callout">
25
-
<!-- similar to <slot /> -->
26
-
<MDCSlot />
15
+
<slot />
27
16
</div>
28
17
</template>
29
18
```
@@ -48,14 +37,14 @@ This usage would be similar to using the native `<slot>` component.
48
37
49
38
### Unwrapping
50
39
51
-
The `unwrap` prop allows you to remove one or multiple wrapping elements from the rendered content. This is useful when you want to extract the content nested in native Markdown syntax. Each specified tag will get removed from AST.
40
+
The `mdc-unwrap` prop allows you to remove one or multiple wrapping elements from the rendered content. This is useful when you want to extract the content nested in native Markdown syntax. Each specified tag will get removed from AST.
52
41
53
42
Let's unwrap the `<p>` element from the previous example:
54
43
55
44
```vue [components/content/Callout.vue]
56
45
<template>
57
46
<div class="callout">
58
-
<MDCSlot unwrap="p" />
47
+
<slot mdc-unwrap="p" />
59
48
</div>
60
49
</template>
61
50
```
@@ -78,9 +67,9 @@ Let's improve our `Callout` component to have a `title` slot:
78
67
<template>
79
68
<div class="callout">
80
69
<h2 v-if="$slots.title">
81
-
<MDCSlot :use="$slots.title" unwrap="p" />
70
+
<slot name="title" mdc-unwrap="p" />
82
71
</h2>
83
-
<MDCSlot :use="$slots.default" />
72
+
<slot />
84
73
</div>
85
74
</template>
86
75
```
@@ -109,10 +98,7 @@ When not using the `title` slot, the `h2` element will not be rendered.
109
98
110
99
## Props
111
100
112
-
-`use`: The slot to bind on, you must provide a `use` via `$slots.{your_slot}` in `<template>`.
113
-
-**Type:** Vue slot `Function`
114
-
-**Example:**`$slots.default`
115
-
-`unwrap`: Whether to unwrap the content or not. This is useful when you want to extract the content nested in native Markdown syntax. Each specified tag will get removed from AST.
101
+
-`mdc-unwrap`: Whether to unwrap the content or not. This is useful when you want to extract the content nested in native Markdown syntax. Each specified tag will get removed from AST.
0 commit comments