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
@@ -64,13 +64,13 @@ We created the MDC syntax to supercharge Markdown and give you the ability to in
64
64
Install the [MDC VS Code extension](https://marketplace.visualstudio.com/items?itemName=Nuxt.mdc) to get proper syntax highlighting for your MDC components.
65
65
::
66
66
67
-
###Front-matter
67
+
## Front-matter
68
68
69
69
Front-matter is a convention of Markdown-based CMS to provide meta-data to pages, like description or title. In Nuxt Content, the front-matter uses the YAML syntax with `key: value` pairs.
70
70
71
71
These data are available when rendering the content and can store any information that you would need.
72
72
73
-
####Syntax
73
+
### Syntax
74
74
75
75
You can declare a front-matter block at the top of the Markdown files in the `content/` directory with the `---` identifier.
76
76
@@ -83,23 +83,93 @@ description: 'meta description of the page'
|`title`|`string`| First `<h1>`{lang="html"} of the page | Title of the page, will also be injected in metas |
91
91
|`description`|`string`| First `<p>`{lang="html"} of the page | Description of the page, will be shown below the title and injected into the metas |
92
-
|`navigation`|`boolean`|`true`| Define if the page is included in [`queryCollectionNavigation`](/docs/utils/query-collection-navigation) return value. |
92
+
|`navigation`|`boolean`|`true`| Define if the page is included in [`queryCollectionNavigation`](/docs/usage/navigation) return value. |
93
93
94
-
### Vue Components
95
94
96
-
Every Vue component created inside the `components/content/` directory will be available in Markdown files.
95
+
## Excerpt
96
+
97
+
Content excerpt or summary can be extracted from the content using `<!--more-->` as a divider.
98
+
99
+
```md [content/index.md]
100
+
---
101
+
title: Introduction
102
+
---
103
+
104
+
Learn how to use `@nuxt/content`.
105
+
106
+
<!--more-->
107
+
108
+
Full amount of content beyond the more divider.
109
+
```
110
+
111
+
Description property will contain the excerpt content unless defined within the Front Matter props.
112
+
113
+
If there is no `<!--more-->` divider in the text then excerpt is undefined.
114
+
115
+
Example variables will be injected into the document:
116
+
117
+
```json
118
+
{
119
+
"excerpt": Object
120
+
"body": Object
121
+
// ... other keys
122
+
}
123
+
```
124
+
125
+
## Code Highlighting
126
+
127
+
Nuxt Content uses [Shiki](https://github.com/shikijs/shiki), that colors tokens with VSCode themes.
128
+
129
+
Code highlighting works both on [`ProsePre`](/docs/components/prose#prosepre) and [`ProseCode`](/docs/components/prose#prosecodeinline).
130
+
131
+
Each line of a code block gets its line number in the `line` attribute so lines can be labeled or individually styled.
132
+
133
+
::callout
134
+
[Read the API reference to configure or entirely disable syntax highlighting.](/get-started/configuration)
135
+
::
136
+
137
+
## Images
138
+
139
+
You can add images to your `public` directory:
140
+
141
+
```bash [Directory structure]
142
+
content/
143
+
index.md
144
+
public/
145
+
image.png
146
+
nuxt.config.ts
147
+
package.json
148
+
```
149
+
150
+
And then use them in your markdown files in the `content` directory as such:
151
+
152
+
```md [content/index.md]
153
+

154
+
```
155
+
156
+
## Vue Components
157
+
158
+
You can use any Vue component in your Markdown files.
159
+
160
+
We have a special syntax to make it easier to use components in your Markdown files.
161
+
162
+
```mdc [content/index.md]
163
+
::component-name
164
+
Default slot content
165
+
::
166
+
```
97
167
98
168
::warning
99
169
Components that are used in Markdown has to be marked as `global` in your Nuxt app if you don't use the `components/content/` directory, visit [Nuxt 3 docs](https://nuxt.com/docs/guide/directory-structure/components) to learn more about it.
100
170
::
101
171
102
-
####Block Components
172
+
### Block Components
103
173
104
174
Block components are components that accept Markdown content or another component as a slot.
105
175
@@ -133,17 +203,17 @@ In a markdown file, use the component with the **`::`** identifier.
133
203
::
134
204
::
135
205
136
-
####Slots
206
+
### Slots
137
207
138
208
A component's slots can accept content or another components.
139
209
140
-
-The **default**slot renders the top-level content inside the block component.
141
-
-**named** slots use the `#` identifier to render the corresponding content.
210
+
-**Default slot** renders the top-level content inside the block component or with `#default`
211
+
-**Named slots** use the `#` identifier to render the corresponding content.
142
212
143
213
::code-group
144
214
```mdc [index.md]
145
215
::hero
146
-
Default slot text
216
+
My Page Title
147
217
148
218
#description
149
219
This will be rendered inside the `description` slot.
@@ -153,119 +223,55 @@ A component's slots can accept content or another components.
153
223
```html [Hero.vue]
154
224
<template>
155
225
<section>
156
-
<h1class="text-4xl"><slot /></h1>
157
-
226
+
<h1class="text-4xl">
227
+
<MDCSlotunwrap="p" />
228
+
</h1>
158
229
<slotname="description" />
159
230
</section>
160
231
</template>
161
232
```
162
233
163
234
::preview-card{label="Preview"}
164
235
::example-hero
165
-
Default slot text
236
+
My Page Title
237
+
166
238
#description
167
239
This will be rendered inside the `description` slot.
168
240
::
169
241
::
170
242
::
171
243
172
-
#### Nesting
244
+
::note
245
+
Read more about the [`<MDCSlot />`](/docs/components/mdc-slot) component.
246
+
::
173
247
174
-
MDC supports nested components inside slots by indenting them.
248
+
::tip
249
+
You can use Markdown inside your components slots:
175
250
176
251
::code-group
177
252
```mdc [index.md]
178
-
::hero
179
-
:::card
180
-
A nested card
181
-
::::card
182
-
A super nested card
183
-
::::
184
-
:::
253
+
::the-title
254
+
A [rich text](/) will be **rendered** by the component.
185
255
::
186
256
```
187
-
188
-
::preview-card{label="Preview"}
189
-
::example-card
190
-
A nested card
191
-
::example-card
192
-
A super nested card
193
-
::
194
-
::
195
-
::
196
-
::
197
-
198
-
::note
199
-
You can add more `::::` when nesting components as a visual reminder.
200
-
::
201
-
202
-
#### Markdown rendering
203
-
204
-
The `<MDCSlot />`{lang="html"} component is auto-imported by Nuxt Content. It acts as a special slot that accepts rich text rendered by Markdown.
205
-
206
-
The `unwrap` prop accepts an HTML tag that will be used to unwrap the content, useful when using tags such as title tags (`<h1>
207
-
`{lang="html"}, `<h2>`{lang="html"}, ...) or inline tags (`<button>`{lang="html"}, `<a>`{lang="html"}, ...).
208
-
209
-
::code-group
210
-
```html [TheTitle.vue]
211
-
<!-- components/content/TheTitle.vue -->
257
+
```html [MyTitle.vue]
212
258
<template>
213
259
<h1class="text-4xl">
214
-
<MDCSlot:use="$slots.default"unwrap="p" />
260
+
<MDCSlotunwrap="p" />
215
261
</h1>
216
262
</template>
217
263
```
218
264
219
-
```mdc [index.md]
220
-
::the-title
221
-
A [rich text](/) will be **rendered** by the component.
222
-
::
223
-
```
224
265
::preview-card{label="Preview"}
225
266
::example-title
226
267
A [rich text](/) will be **rendered** by the component.
227
268
::
228
269
::
229
270
230
271
::
231
-
232
-
The `<MDCSlot />` component can act as a named slot with the `use` property:
233
-
234
-
```html
235
-
<MDCSlot:use="$slots.description"unwrap="p">
236
-
```
237
-
238
-
#### Inline components
239
-
240
-
Inline components are components without slots or `<MDCSlot />`.
241
-
242
-
They can be used with the `:` identifier.
243
-
244
-
::code-group
245
-
```mdc [index.md]
246
-
# Title
247
-
248
-
:banner
249
-
```
250
-
251
-
```html [Banner.vue]
252
-
<template>
253
-
<aside>
254
-
This component does not have any children.
255
-
</aside>
256
-
</template>
257
-
```
258
272
::
259
273
260
-
If you want to use an inline component followed by specific characters like `-`, `_` or `:`, you can use a dummy props specifier after it.
261
-
262
-
```mdc
263
-
:hello{}-world
264
-
```
265
-
266
-
In this example, `:hello{}` will search for the `<Hello />` component, and `-world` will be plain text.
267
-
268
-
#### Props
274
+
### Props
269
275
270
276
There are two ways to pass props to components using MDC.
271
277
@@ -394,28 +400,14 @@ The YAML method uses the `---` identifier to declare one prop per line, that can
394
400
::
395
401
::
396
402
397
-
#### Span Text
398
-
399
-
To create inline spans in your text you can use the `[]` identifier.
0 commit comments