npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vitepress-vue-demo

v1.0.10

Published

vitepress-vue-demo 是一个基于 Vitepress 开发的插件,它可以帮助你在编写文档的时候,通过`路径引用`,直接展示 `Vue 组件示例 + 代码`。

Downloads

25

Readme

vitepress-vue-demo

简介

vitepress-vue-demo 是一个基于 Vitepress 开发的插件,它可以帮助你在编写文档的时候,通过路径引用,直接展示 Vue 组件示例 + 代码

灵感来源:element-plus源码

demo

安装

npm install -D vitepress-vue-demo
yarn add -D vitepress-vue-demo
pnpm add -D vitepress-vue-demo

使用

1、docs/.vitepress/config.ts 中为markdown增加扩展

// .vitepress/config.ts
import { defineConfig } from 'vitepress'
import { mdVueDemoPlugin } from 'vitepress-vue-demo'


// https://vitepress.dev/reference/site-config
export default defineConfig({
  ...
  markdown: {
    config: (md) => {
      md.use(mdVueDemoPlugin)
    }
  }
})

2、docs/.vitepress/theme/index.ts 中注册组件。

将你项目中所有vue示例组件,统一放到一个目录下,例如docs/demos

然后通过vite的import.meta.glob模块,将这个目录下所有vue组件导入进来,传给mdVueDemo组件即可!

// .vitepress/theme/index.ts
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import type { Component } from 'vue'
import { mdVueDemo } from 'vitepress-vue-demo'
import 'vitepress-vue-demo/dist/style.css'

const modules = import.meta.glob<Component>('../../demos/**/*', { eager: true, import: 'default' })

export default {
  extends: DefaultTheme,
  enhanceApp({ app }) {
     app.use(mdVueDemo, { modules })
  }
} satisfies Theme

3、在你的文档中,可以通过路径直接展示组件了!


## 按钮组件

::: demo

demos/Button.vue

:::

更多用法

1、默认展开代码


::: demo expand

demos/Button.vue

:::

2、展示tsx组件


::: demo

demos/Button.tsx

:::