shiki
Demo
ts
// .vitepress/config.ts
import { defineConfig } from 'vitepress'
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
export default defineConfig({
markdown: {
codeTransformers: [
transformerTwoslash()
]
}
})
vue
<script setup>
import { onMounted, ref } from 'vue'
// reactive state
const count = ref(0)
// functions that mutate state and trigger updates
function increment() {
count.value++
}
// lifecycle hooks
onMounted(() => {
console.log(`The initial count is ${count.value}.`)
})
</script>
<template>
<button @click="increment">
Count is: {{ count }}
</button>
</template>
js
/**
* @type {import('vitepress').UserConfig}
*/
const config = {
// ...
}
export default config
ts
import type { UserConfig } from 'vitepress'
const config: UserConfig = {
// ...
}
export default config