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

@panda-jia/vitepress-demo

v0.2.0-4

Published

@panda-jia/vitepress-demo 基于 shadow DOM 扩充 vitepress 的 DEMO 演示能力,降低编写 DEMO 的难度,简化展示示例的配置。

Downloads

5

Readme

@panda-jia/vitepress-demo

@panda-jia/vitepress-demo 基于 shadow DOM 扩充 vitepress 的 DEMO 演示能力,降低编写 DEMO 的难度,简化展示示例的配置。

背景

vitepress DEMO 演示的问题

  • vitepress 演示组件和代码需要各自配置一份。
  • vitepress 的公共样式会影响 DEMO 内部的样式。

解决想法

  • 通过配置只用一份代码完成组件的 DEMO 演示和代码展示。
  • 使用 shadow DOM 自带的特性实现代码样式隔离。

安装

npm install @panda-jia/vitepress-demo

使用

Markdown 解析插件

在 .vitepress/config 内注册 Markdown 解析插件

import demoTransform from '@panda-jia/vitepress-demo/plugin'
// import { componentTransform } from '@panda-jia/vitepress-demo/plugin'

export default {
    markdown: {
        config(md) {
            md.use(componentTransform,
                // {
                //     componentName: 'demo'
                //     style:  ['.class-name{width:100px}'],
                //     cssUrl: ['../index.scss']
                // }
            )
        },
    },
}

DEMO 组件

在 .vitepress/theme/index 内注册 DEMO 组件

import DefaultTheme from 'vitepress/theme'
import DemoPreview from '@panda-jia/vitepress-demo/component'

export default {
    ...DefaultTheme,
    enhanceApp({ app }) {
        app.component('demo', DemoPreview)
    },
}

在 Markdown 文件中使用

<demo path="../../../src/components/button/index.vue"></demo>

componentTransform 配置

Markdown 插件支持以下入参,示例看上方:

interface Option {
    componentName?: string
    style?: string | string[]
    cssUrl?: string | string[]
}
  • componentName

    @panda-jia/vitepress-demo 希望将 DEMO 组件注册为 ,但不排除注册为其它名字的情况,这时需要将注册名传入插件。

  • style

    shadow DOM 内部公共样式配置。

  • cssUrl

    shadow DOM 内部公共样式配置。

问题

已知问题解答