@karry-design/vitepress-plugin-demo-component
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@karry-design/vitepress-plugin-demo-component

Demo of Vue SFC components in vitepress

🎉 Introduce

We can see their component display and code example display from some excellent UI component libraries such as element-plus and Ant Design Vue

This project is based on vitepress and markdown-it implementation to display components and code examples in documents. Using this plug-in, Vue SFC components can be displayed in static documents

🏄‍♂️ Packages

⚙️ Installation

pnpm add @karry-design/vitepress-plugin-demo-component @karry-design/vitepress-plugin-demo-preview

⚡ Usage

configure in your vitepress/theme entry file

import { AntDesignContainer, ElementPlusContainer, NaiveUIContainer } from '@vitepress-demo-preview/component'
import '@vitepress-demo-preview/component/dist/style.css'

export default {
  ...DefaultTheme,
  enhanceApp({ app }: { app: App }) {
    app.component('demo-preview', AntDesignContainer)
  }
}

configure markdown to add plugin

import { defineConfig } from 'vitepress'
import { containerPreview, componentPreview } from '@vitepress-demo-preview/plugin'

export default defineConfig({
  markdown: {
    config(md) {
      md.use(containerPreview)
      md.use(componentPreview)
    }
  }
})

Preview of Component Form

### Single-line

<Preview path="./components/ComponentPreview.vue" title="Component Preview"></Preview>

### Multi-line

<Preview 
  path="./components/ComponentPreview.vue" 
  title="Component Preview" 
></Preview>

### Multi-line Description

<Preview 
  path="./components/ComponentPreview.vue" 
  title="Component Preview" 
  description="Preview By Component Form"
>
  <template #description>
    <h1>this is slot data</h1>
    <h2> level</h2>
  </template>
</Preview>

### Single-line Description

<Preview path="./components/ComponentPreview.vue" title="Component Preview" description="Preview By Component Form"></Preview>

API

Name Description Explanation
path Demo path Cannot be left blank
title Explanation -
description Description -
noCode Do not display code Default false

Slots

  • description: Extension for descriptive content.

📑 License

Package Sidebar

Install

npm i @karry-design/vitepress-plugin-demo-component

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

41.9 kB

Total Files

17

Last publish

Collaborators

  • 549689251_gdd
  • homehow
  • kkk1204
  • ektx
  • lzwcl