Skip to content

Commit

Permalink
try nuxt-shiki for command blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 4, 2024
1 parent b265a1b commit 1f7a526
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/components/global/Pm-x.vue
Expand Up @@ -17,21 +17,26 @@ onMounted(() => {
useSyncedPackageManager(codeBlocks, toRef(codeGroup.value, 'selectedIndex'))
}
})
const themes = {
dark: 'min-dark',
light: 'min-light',
}
</script>

<template>
<CodeGroup ref="codeGroup">
<ProseCode v-bind="codeBlocks[0]">
<pre><code>{{ codeBlocks[0].code }}</code></pre>
<Shiki :code="codeBlocks[0].code" lang="sh" :themes="themes" as="span" />
</ProseCode>
<ProseCode v-bind="codeBlocks[1]">
<pre><code>{{ codeBlocks[1].code }}</code></pre>
<Shiki :code="codeBlocks[0].code" lang="sh" :themes="themes" as="span" />
</ProseCode>
<ProseCode v-bind="codeBlocks[2]">
<pre><code>{{ codeBlocks[2].code }}</code></pre>
<Shiki :code="codeBlocks[0].code" lang="sh" :themes="themes" as="span" />
</ProseCode>
<ProseCode v-bind="codeBlocks[3]">
<pre><code>{{ codeBlocks[3].code }}</code></pre>
<Shiki :code="codeBlocks[0].code" lang="sh" :themes="themes" as="span" />
</ProseCode>
</CodeGroup>
</template>
5 changes: 5 additions & 0 deletions app/nuxt.config.ts
Expand Up @@ -13,6 +13,7 @@ const isPrepare = Boolean(process.env.NUXT_DOCS_PREPARE)
export default defineNuxtConfig({
ssr,
modules: [
'nuxt-shiki',
'@nuxt/content',
'@nuxtjs/fontaine',
!isPrepare && '@nuxtjs/google-fonts',
Expand Down Expand Up @@ -59,6 +60,10 @@ export default defineNuxtConfig({
langs: ['json5', 'jsonc', 'toml', 'yaml', 'html', 'sh', 'shell', 'bash', 'mdc', 'markdown', 'md'],
},
},
shiki: {
langs: ['json5', 'jsonc', 'toml', 'yaml', 'html', 'sh', 'shell', 'bash', 'mdc', 'markdown', 'md'],
themes: ['min-dark', 'min-light'],
},
routeRules: {
'/api/search.json': { prerender: true },
},
Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -48,6 +48,7 @@
"nuxi": "^3.10.1",
"nuxt": "^3.10.3",
"nuxt-build-cache": "^0.1.1",
"nuxt-shiki": "^0.1.2",
"pkg-types": "^1.0.3",
"scule": "^1.3.0",
"tailwindcss": "^3.4.1",
Expand Down

0 comments on commit 1f7a526

Please sign in to comment.