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
That's it! You can start writing and rendering markdown files ✨
48
48
49
-
## Parsing Markdown
50
-
51
-
Nuxt MDC exposes a handy helper to parse MDC files. You can import the `parseMarkdown` function from `@nuxtjs/mdc/runtime` and use it to parse markdown files written with MDC syntax.
`@nuxtjs/mdc` exposes three components to render markdown files.
68
52
69
-
returnast
70
-
})
71
-
```
53
+
### `<MDC>`
72
54
73
-
### Browser
55
+
Using `<MDC>`, you can parse and render markdown contents right inside your components/pages. This component takes raw markdown, parses it using the `parseMarkdown` function, and then renders it with `<MDCRenderer>`.
74
56
75
-
The `parseMarkdown` function is a universal helper, and you can also use it in the browser, for example inside a Vue component.
57
+
```html
58
+
<scriptsetuplang="ts">
59
+
constmd=`
60
+
::alert
61
+
Hello MDC
62
+
::
63
+
`
64
+
</script>
76
65
77
-
```vue [mdc-test.vue]
78
66
<template>
79
-
<div>This is a test</div>
67
+
<MDC:value="md"tag="article" />
80
68
</template>
81
-
82
-
<script setup lang="ts">
83
-
import { parseMarkdown } from '@nuxtjs/mdc/runtime'
The `parseMarkdown` helper also accepts options as the second argument to control the parser's behavior. (Checkout [`MDCParseOptions` interface↗︎](https://github.com/nuxt-modules/mdc/blob/main/src/runtime/types/parser.ts)).
`@nuxtjs/mdc` exposes three components to render markdown files.
114
-
115
71
### `<MDCRenderer>`
116
72
117
73
This component will take the result of [`parseMarkdown`](#parsing-markdown) function and render the contents. For example, this is an extended version of the sample code in the [Browser section](#browser) which uses `MDCRenderer` to render the parsed markdown.
@@ -165,24 +114,6 @@ It is the default behavior of markdown to wrap every text inside a paragraph. MD
165
114
</template>
166
115
```
167
116
168
-
### `<MDC>`
169
-
170
-
Using `<MDC>`, you can parse and render markdown contents right inside your components/pages. This component takes raw markdown, parses it using the `parseMarkdown` function, and then renders it with `<MDCRenderer>`.
171
-
172
-
```html
173
-
<template>
174
-
<MDC:value="md"tag="article" />
175
-
</template>
176
-
177
-
<scriptsetuplang="ts">
178
-
constmd=`
179
-
::alert
180
-
Hello MDC
181
-
::
182
-
`
183
-
</script>
184
-
```
185
-
186
117
### Prose Components
187
118
188
119
Prose components are a list of components that will be rendered instead of regular HTML tags. For example, instead of rendering a `<p>` tag, `@nuxtjs/mdc` renders a `<ProseP>` component. This is useful when you want to add extra features to your markdown files. For example, you can add a `copy` button to your code blocks.
@@ -232,11 +163,67 @@ Here is the list of available prose components:
Nuxt MDC exposes a handy helper to parse MDC files. You can import the `parseMarkdown` function from `@nuxtjs/mdc/runtime` and use it to parse markdown files written with MDC syntax.
The `parseMarkdown` helper also accepts options as the second argument to control the parser's behavior. (Checkout [`MDCParseOptions` interface↗︎](https://github.com/nuxt-modules/mdc/blob/main/src/runtime/types/parser.ts)).
0 commit comments