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: README.md
+47-5Lines changed: 47 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,9 @@ Nuxt Module to compile markdown files into Vue SFC at **build time**. This enabl
9
9
10
10
- 📚 Write pages & components in Markdown
11
11
- 💚 Use Vue components in Markdown.
12
-
- 👌 Support SEO & Page metas
12
+
- 👌 Support SEO & Page Meta
13
+
- 📦 Built-in support for [MDC (Markdown Components)](https://remark-mdc.nuxt.space/)
14
+
- 🧑💻 Syntax highlighting with light/dark mode support
13
15
14
16
## Install
15
17
@@ -46,7 +48,7 @@ pages/
46
48
index.md
47
49
```
48
50
49
-
## SEO & Page metas
51
+
## SEO & Page Meta
50
52
51
53
Use the `seo` property in the frontmatter to leverage [`useSeoMeta()`](https://nuxt.com/docs/api/composables/use-seo-meta):
52
54
@@ -64,7 +66,7 @@ seo:
64
66
65
67
Will be transformed to:
66
68
67
-
```vue
69
+
```html
68
70
<scriptsetup>
69
71
useSeoMeta({
70
72
title:'My title',
@@ -93,7 +95,7 @@ meta:
93
95
94
96
Will be transformed to:
95
97
96
-
```vue
98
+
```html
97
99
<scriptsetup>
98
100
definePageMeta({
99
101
layout:'dark',
@@ -137,6 +139,16 @@ I can use a Markdown component:
137
139
<HelloWorld />
138
140
```
139
141
142
+
[MDC (Markdown Components)](https://remark-mdc.nuxt.space/) support is also built-in, meaning you can also do:
143
+
144
+
```md
145
+
Inline :my-component{name="World"} syntax.
146
+
147
+
::HelloWorld
148
+
And also **block** syntax{.text-green}
149
+
::
150
+
```
151
+
140
152
If the Markdown is not inside the `components/` directory, you can import it and use it as a normal Vue component:
141
153
142
154
```vue
@@ -149,6 +161,36 @@ import Readme from '../README.md'
149
161
</template>
150
162
```
151
163
164
+
## Syntax Highlighting
165
+
166
+
We have [`shiki`](https://github.com/shikijs/shiki) built-in for syntax highlighting (actually uses [`shikiji`](https://github.com/antfu/shikiji), a ESM build of `shiki`). It's enabled by default and supports light/dark mode out of the box.
167
+
168
+
To apply the dark mode theme, you will need to add a bit of CSS:
You can learn more about the [Dual Themes suppport](https://github.com/antfu/shikiji#lightdark-dual-themes).
193
+
152
194
## `<script>` and `<style>`
153
195
154
196
Root-level `<script>` and `<style>` tags in Markdown files work just like they do in Vue SFCs, including `<script setup>`, `<style module>`, etc. The main difference here is that there is no `<template>` tag: all other root-level content is Markdown. Also note that all tags should be placed after the frontmatter:
@@ -175,7 +217,7 @@ The count is: {{ count }}
175
217
176
218
### How does this compare to [@nuxt/content](https://content.nuxtjs.org/)?
177
219
178
-
`nuxt-compile-markdown` works at built time and converts the Markdown files to Vue files for maximum performance. This module does not have the ability to query content like [Nuxt Content Query Builder](https://content.nuxtjs.org/guide/displaying/querying). Also `nuxt-compile-markdown` does not support the MDC syntax (for now).
220
+
`nuxt-compile-markdown` works at built time and converts the Markdown files to Vue files for maximum performance. This module does not have the ability to query content like [Nuxt Content Query Builder](https://content.nuxtjs.org/guide/displaying/querying).
0 commit comments