Skip to content

Commit 28c49c0

Browse files
authored
chore: deprecate markdown component (#1435)
1 parent 1dc3589 commit 28c49c0

File tree

18 files changed

+152
-84
lines changed

18 files changed

+152
-84
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
22
<h1 class="text-4xl">
3-
<Markdown :use="$slots.default" unwrap="p" />
3+
<ContentSlot :use="$slots.default" unwrap="p" />
44
</h1>
55
</template>

docs/components/content/MyButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defineProps({
99

1010
<template>
1111
<button :class="type">
12-
<Markdown :use="$slots.default" unwrap="p" />
12+
<ContentSlot :use="$slots.default" unwrap="p" />
1313
</button>
1414
</template>
1515

docs/content/3.guide/1.writing/3.mdc.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Any component in the `components/content/` directory or [made available globally
1616
The component must contain either:
1717

1818
- A `<slot />`{lang="html"} to accept raw text or another component.
19-
- The `<Markdown />`{lang="html"} component to accept formatted text.
19+
- The `<ContentSlot />`{lang="html"} component to accept formatted text.
2020

2121
In a markdown file, use the component with the **`::`** identifier.
2222

@@ -107,15 +107,15 @@ You can add more `::::` when nesting components as a visual reminder.
107107

108108
### Markdown rendering
109109

110-
The `<Markdown />`{lang="html"} component is auto-imported by Nuxt Content. It acts as a special slot that accepts rich text rendered by Markdown.
110+
The `<ContentSlot />`{lang="html"} component is auto-imported by Nuxt Content. It acts as a special slot that accepts rich text rendered by Markdown.
111111

112112
The `unwrap` prop accepts an HTML tag that will be used to unwrap the content, useful when using tags such as title tags (`<h1>`{lang="html"}, `<h2>`{lang="html"}, ...) or inline tags (`<button>`{lang="html"}, `<a>`{lang="html"}, ...).
113113

114114
::code-group
115115
```html [TheTitle.vue]
116116
<template>
117117
<h1 class="text-4xl">
118-
<Markdown :use="$slots.default" unwrap="p" />
118+
<ContentSlot :use="$slots.default" unwrap="p" />
119119
</h1>
120120
</template>
121121
```
@@ -131,15 +131,15 @@ The `unwrap` prop accepts an HTML tag that will be used to unwrap the content, u
131131
::
132132
::
133133

134-
The `<Markdown />` component can act as a named slot with the `use` property:
134+
The `<ContentSlot />` component can act as a named slot with the `use` property:
135135

136136
```html
137-
<Markdown :use="$slots.description" unwrap="p">
137+
<ContentSlot :use="$slots.description" unwrap="p">
138138
```
139139

140140
## Inline components
141141

142-
Inline components are components without slots or `<Markdown />`.
142+
Inline components are components without slots or `<ContentSlot />`.
143143

144144
They can be used with the `:` identifier.
145145

@@ -189,7 +189,7 @@ defineProps(['type'])
189189

190190
<template>
191191
<div :class="[type]">
192-
<Markdown :use="$slots.default" unwrap="p" />
192+
<ContentSlot :use="$slots.default" unwrap="p" />
193193
</div>
194194
</template>
195195
```

docs/content/4.api/1.components/5.markdown.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ title: '<Markdown>'
33
description: 'The fastest way to inject Markdown into your Vue components.'
44
---
55

6+
::alert{type=danger}
7+
**NOTE**: As of [email protected] this component is deprecated and replaced by [`<ContentSlot>`](./content-slot).
8+
::
9+
610
The `<Markdown>`{lang=html} component makes it easier to use Markdown syntax in your Vue components.
711

812
It is useful when creating components that you want to use in your Markdown content.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: '<ContentSlot>'
3+
description: 'The fastest way to inject Markdown into your Vue components.'
4+
---
5+
6+
The `<ContentSlot>`{lang=html} component makes it easier to use Markdown syntax in your Vue components.
7+
8+
It is useful when creating components that you want to use in your Markdown content.
9+
10+
## Props
11+
12+
- `use`{lang=ts}: The slot to bind on, you must provide a `use`{lang=ts} via `$slots.{your_slot}`{lang=ts} in `<template>`{lang=html}.
13+
- Type: Vue slot `Function`
14+
- Example: `$slots.default`{lang=ts}
15+
- `unwrap`{lang=ts}: 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.
16+
- Type: `Boolean`{lang=ts} or `String`{lang=ts}
17+
- Default: `false`{lang=ts}
18+
- Example: `'ul li'`{lang=ts}
19+
20+
## Example
21+
22+
```html [components/FancyHeader.vue]
23+
<template>
24+
<h2 class="fancy-header"><ContentSlot :use="$slots.default" unwrap="p" /></h2>
25+
</template>
26+
```
27+
28+
```md [content/index.md]
29+
::fancy-header
30+
That text paragraph will be unwrapped.
31+
::
32+
```
File renamed without changes.

docs/content/4.api/2.composables/3.unwrap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
title: 'useUnwrap()'
33
---
44

5-
It can be used to achieve a similar behavior as `unwrap`{lang=ts} prop from `<Markdown>`{lang=html} component.
5+
It can be used to achieve a similar behavior as `unwrap`{lang=ts} prop from `<ContentSlot>`{lang=html} component.

docs/content/5.examples/3.mdc/2.nested-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: 'Nested components'
44
description: 'The MDC syntax allow you to nest components within a parent slot using indentation and the :: syntax.'
55
---
66

7-
The `components/AppNested.vue` component uses the `<Markdown>` component as markdown-rendering slot.
7+
The `components/AppNested.vue` component uses the `<ContentSlot>` component as markdown-rendering slot.
88

99
::ReadMore{link="/guide/writing/mdc#nesting"}
1010

docs/content/6.blog/1.announcing-v2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ MDC is Markdown, so nothing changes and you can keep using the `.md` extension.
205205

206206
<template>
207207
<button :class="type">
208-
<Markdown :use="$slots.default" unwrap="p" />
208+
<ContentSlot :use="$slots.default" unwrap="p" />
209209
</button>
210210
</template>
211211
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<aside>
33
<h2>Nested component</h2>
4-
<Markdown unwrap="p" />
4+
<ContentSlot unwrap="p" />
55
</aside>
66
</template>

0 commit comments

Comments
 (0)