diff --git a/apps/www/.vitepress/config.mts b/apps/www/.vitepress/config.mts index 78e6b8e1..b4920fbc 100644 --- a/apps/www/.vitepress/config.mts +++ b/apps/www/.vitepress/config.mts @@ -1,6 +1,7 @@ import path from 'node:path' import { defineConfig } from 'vitepress' import Icons from 'unplugin-icons/vite' +import ComponentPreviewPlugin from './theme/plugins/previewer' // https://vitepress.dev/reference/site-config export default defineConfig({ @@ -9,6 +10,9 @@ export default defineConfig({ srcDir: path.resolve(__dirname, '../src/content'), markdown: { theme: 'css-variables', + config(md) { + md.use(ComponentPreviewPlugin) + }, }, vite: { plugins: [ diff --git a/apps/www/.vitepress/theme/components/ComponentPreview.vue b/apps/www/.vitepress/theme/components/ComponentPreview.vue index b27318d4..4e16598a 100644 --- a/apps/www/.vitepress/theme/components/ComponentPreview.vue +++ b/apps/www/.vitepress/theme/components/ComponentPreview.vue @@ -7,6 +7,8 @@ import { cn } from '@/lib/utils' const props = withDefaults(defineProps<{ name: string align?: 'center' | 'start' | 'end' + sfcTsCode?: string + sfcTsHtml?: string }>(), { align: 'center' }) const Component = defineAsyncComponent({ @@ -17,7 +19,9 @@ const Component = defineAsyncComponent({