Skip to content

Commit b01e543

Browse files
committed
docs: add shikiji example
1 parent 3e1994c commit b01e543

File tree

5 files changed

+72
-5
lines changed

5 files changed

+72
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"changelogen": "^0.5.4",
4343
"eslint": "^8.47.0",
4444
"nuxt": "^3.6.5",
45+
"shikiji": "^0.5.0",
4546
"vitest": "^0.34.2"
4647
}
4748
}

playground/app.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,25 @@
33
<NuxtPage />
44
</NuxtLayout>
55
</template>
6+
7+
<style>
8+
html {
9+
font-family: Arial, Helvetica, sans-serif;
10+
}
11+
12+
html.dark {
13+
color-scheme: dark;
14+
}
15+
16+
.shiki {
17+
padding: 0.6rem;
18+
border-radius: 0.2rem;
19+
border: 1px solid #8882;
20+
}
21+
22+
html.dark .shiki,
23+
html.dark .shiki span {
24+
color: var(--s-dark) !important;
25+
background-color: var(--s-dark-bg) !important;
26+
}
27+
</style>

playground/nuxt.config.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1+
import { bundledLanguages, getHighlighter } from 'shikiji'
2+
13
export default defineNuxtConfig({
4+
// builder: 'webpack',
25
modules: ['../src'],
36
devtools: { enabled: true },
47
nitro: {
58
prerender: {
69
ignore: ['/redirect'],
710
},
811
},
9-
// builder: 'webpack',
12+
markdown: {
13+
async markdownItSetup(md) {
14+
const shiki = await getHighlighter({
15+
themes: ['vitesse-dark', 'vitesse-light'],
16+
langs: Object.keys(bundledLanguages) as any,
17+
})
18+
19+
md.use((markdown) => {
20+
markdown.options.highlight = (code, lang) => {
21+
return shiki.codeToHtml(code, {
22+
lang,
23+
themes: {
24+
light: 'vitesse-light',
25+
dark: 'vitesse-dark',
26+
},
27+
cssVariablePrefix: '--s-',
28+
})
29+
}
30+
})
31+
},
32+
},
1033
})

playground/pages/index.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,26 @@ Nuxt Page as Markdown
2020

2121
---
2222

23-
For [Nuxt](http://nuxt.com/)
24-
25-
Checkout the [about page](/about) or the [blog](/blog).
26-
2723
```ts
2824
export default defineNuxtConfig({
2925
// Hello World
3026
})
3127
```
28+
29+
~~~md
30+
# Markdown
31+
32+
And **nested** code blocks
33+
34+
```rs
35+
fn main() {
36+
println!("Hello World!");
37+
}
38+
```
39+
~~~
40+
41+
---
42+
43+
For [Nuxt](http://nuxt.com/)
44+
45+
Checkout the [about page](/about) or the [blog](/blog).

pnpm-lock.yaml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)