Skip to content

Commit 705d63e

Browse files
committed
docs: more improvements
1 parent a0099fd commit 705d63e

File tree

7 files changed

+238
-200
lines changed

7 files changed

+238
-200
lines changed

docs/app/components/PreviewCard.vue

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

1010
<template>
1111
<div
12-
class="p-4 border rounded-b-md border-[--ui-color-neutral-200] dark:border-[--ui-color-neutral-700] bg-[--ui-color-neutral-50] dark:bg-[--ui-color-neutral-800] dark:text-white"
13-
:class="prose ? 'prose' : 'not-prose'"
12+
class="px-4 py-1 border rounded-b-md border-[var(--ui-color-neutral-200)] dark:border-[var(--ui-color-neutral-700)] bg-[var(--ui-color-neutral-50)] dark:bg-[var(--ui-color-neutral-800)] dark:text-white"
1413
>
1514
<slot />
1615
</div>

docs/app/components/example/ExampleHero.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
2-
<section>
2+
<section class="pt-4">
33
<h1 class="text-4xl">
4-
<slot />
4+
<MDCSlot unwrap="p" />
55
</h1>
66
<slot name="description" />
77
</section>

docs/content/docs/3.files/1.markdown.md

Lines changed: 102 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ We created the MDC syntax to supercharge Markdown and give you the ability to in
6464
Install the [MDC VS Code extension](https://marketplace.visualstudio.com/items?itemName=Nuxt.mdc) to get proper syntax highlighting for your MDC components.
6565
::
6666

67-
### Front-matter
67+
## Front-matter
6868

6969
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.
7070

7171
These data are available when rendering the content and can store any information that you would need.
7272

73-
#### Syntax
73+
### Syntax
7474

7575
You can declare a front-matter block at the top of the Markdown files in the `content/` directory with the `---` identifier.
7676

@@ -83,23 +83,93 @@ description: 'meta description of the page'
8383
<!-- Content of the page -->
8484
```
8585

86-
#### Native parameters
86+
### Native parameters
8787

8888
| Key | Type | Default | Description |
8989
| ------------------------------------------- | :-------: | ------------------------------------- | -------------------------------------------------------------------------------------------------------- |
9090
| `title` | `string` | First `<h1>`{lang="html"} of the page | Title of the page, will also be injected in metas |
9191
| `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. |
9393

94-
### Vue Components
9594

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+
![my image](/image.png)
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+
```
97167

98168
::warning
99169
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.
100170
::
101171

102-
#### Block Components
172+
### Block Components
103173

104174
Block components are components that accept Markdown content or another component as a slot.
105175

@@ -133,17 +203,17 @@ In a markdown file, use the component with the **`::`** identifier.
133203
::
134204
::
135205

136-
#### Slots
206+
### Slots
137207

138208
A component's slots can accept content or another components.
139209

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.
142212

143213
::code-group
144214
```mdc [index.md]
145215
::hero
146-
Default slot text
216+
My Page Title
147217
148218
#description
149219
This will be rendered inside the `description` slot.
@@ -153,119 +223,55 @@ A component's slots can accept content or another components.
153223
```html [Hero.vue]
154224
<template>
155225
<section>
156-
<h1 class="text-4xl"><slot /></h1>
157-
226+
<h1 class="text-4xl">
227+
<MDCSlot unwrap="p" />
228+
</h1>
158229
<slot name="description" />
159230
</section>
160231
</template>
161232
```
162233

163234
::preview-card{label="Preview"}
164235
::example-hero
165-
Default slot text
236+
My Page Title
237+
166238
#description
167239
This will be rendered inside the `description` slot.
168240
::
169241
::
170242
::
171243

172-
#### Nesting
244+
::note
245+
Read more about the [`<MDCSlot />`](/docs/components/mdc-slot) component.
246+
::
173247

174-
MDC supports nested components inside slots by indenting them.
248+
::tip
249+
You can use Markdown inside your components slots:
175250

176251
::code-group
177252
```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.
185255
::
186256
```
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]
212258
<template>
213259
<h1 class="text-4xl">
214-
<MDCSlot :use="$slots.default" unwrap="p" />
260+
<MDCSlot unwrap="p" />
215261
</h1>
216262
</template>
217263
```
218264

219-
```mdc [index.md]
220-
::the-title
221-
A [rich text](/) will be **rendered** by the component.
222-
::
223-
```
224265
::preview-card{label="Preview"}
225266
::example-title
226267
A [rich text](/) will be **rendered** by the component.
227268
::
228269
::
229270

230271
::
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-
```
258272
::
259273

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
269275

270276
There are two ways to pass props to components using MDC.
271277

@@ -394,28 +400,14 @@ The YAML method uses the `---` identifier to declare one prop per line, that can
394400
::
395401
::
396402

397-
#### Span Text
398-
399-
To create inline spans in your text you can use the `[]` identifier.
400-
401-
::code-group
402-
```mdc [Code]
403-
Hello [World]{style="background-color: var(--color-primary-500)"}!
404-
```
405-
406-
::preview-card{label="Preview"}
407-
Hello [World]{style="background-color: var(--color-primary-500)"}!
408-
::
409-
::
410-
411-
#### Attributes
403+
### Attributes
412404

413405
Attributes are useful for highlighting and modifying part of paragraph. The syntax is nearly similar to inline components and markdown links syntax.
414406

415407
Possible values ​​are all named attributes, classes with the notation `.class-name` and an ID with `#id-name`.
416408

417409
::code-group
418-
```mdc [Code]
410+
```mdc [index.md]
419411
Hello [World]{style="color: green;" .custom-class #custom-id}!
420412
```
421413

@@ -427,7 +419,7 @@ Possible values ​​are all named attributes, classes with the notation `.clas
427419
In addition to mdc components and `span`, attribute syntax will work on images, links, inline `code`, **bold** and _italic_ text.
428420

429421
::code-group
430-
```md [Code]
422+
```md [index.md]
431423
Attributes work on:
432424

433425
- ![](/favicon.ico){style="display: inline; margin: 0;"} image,
@@ -543,7 +535,7 @@ const mdcVars = ref({ name: 'Maxime'});
543535
544536
```
545537

546-
### Prose Components
538+
## Prose Components
547539

548540
In Nuxt Content, the prose represents HTML tags generated by the Markdown syntax, such as heading levels and links.
549541

@@ -556,6 +548,6 @@ If you want to customize a Prose component, here are the recommended steps:
556548
- In your `components/content/` directory, give it the same name.
557549
- Make it yours 🚀.
558550

559-
::callout
560-
Read the complete Prose reference in the [Prose Components section](/docs/components/prose).
551+
::note{to="/docs/components/prose"}
552+
Read the complete Prose reference in the Prose Components section.
561553
::

0 commit comments

Comments
 (0)