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-plugin-demoblock

v1.0.10

Published

A vite plugin that helps vitepress generate vue component code blocks.

Downloads

36

Readme

vite-plugin-vitepress-demo

A vite plugin that helps vitepress generate vue component code blocks.

English | 简体中文

banner

If you are using vuepress now, and you also want to achieve similar functions, you can try vuepress-plugin-code-block

Install

npm i vite-plugin-vitepress-demo -D

Plugin configuration

The plugin is Pure ESM, make sure your package.json contains "type": "module".

In vite.config.[jt]s:

import { defineConfig } from 'vite'
import PluginVitePressDemoBlock from 'vite-plugin-vitepress-demo'

export default defineConfig({
  plugins: [
    PluginVitePressDemoBlock(),
  ],
})

Plugin options

  • glob: string | string[]

    Specify the files to be processed, support glob syntax, default to ./**/examples/*.{vue,ts,tsx}.

  • base: string

    Specify the folder to listen from, default to vite config root.

  • exclude: string[]

    Specify the files to be excluded, support glob syntax, default to ['**/node_modules/**', '**/dist/**', '**/build/**', '**/test/**', '**/tests/**', '**/__tests__/**']. If you don't want to exclude .vitepress, you can set exclude:[].

  • markdown: Same to vitepress config markdown.

Experimental

At present, the support for jsx is still in the experimental stage, and there may be some unstable places. If you find bug, you can submit an issue to us.

Component configuration

We support custom component in 2.x version.

But it needs to be consistent with our props.

If our built-in themes do not meet your needs, you can refer to our default theme to customize your own theme.

At the same time, everyone is welcome to submit PR to make our theme more perfect.

Usage Component

In .vitepress/theme/index.[jt]s:

import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { AntdTheme } from 'vite-plugin-vitepress-demo/theme'

export default {
  ...DefaultTheme,
  enhanceApp({ app }) {
    app.component('Demo', AntdTheme)
  },
} as Theme

Import Source Code

<demo src="./demos/basic.vue"></demo>

Usage markdown In vue file

demos/basic.vue:

<docs>
---
title: Test Title
---

Hello World This is Test Docs block code in `docs.vue`.

</docs>

<template>
  <div>
    {{ msg }}
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

const msg = ref('Hello World')
</script>

In markdown:

<demo src="./demos/docs.vue"></demo>