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

sunhshine-vitepress-theme-demoblock

v0.0.1

Published

vitepress-theme-demoblock

Downloads

4

Readme

Vitepress-Theme-Demoblock

简介

Vitepress-Theme-Demoblock 是一个基于 Vitepress 的主题插件,它可以帮助你在编写文档的时候增加 Vue 示例,它的诞生初衷是为了降低编写组件文档时增加一些相关示例的难度。

使用 Vitepress 编写组件示例有以下不足之处:

  • 1.组件示例和示例代码本质上一样,却需要写两遍。
  • 2.Vitepress 无法渲染 Markdown 中的 script 和 style 代码块。

Vitepress-Theme-Demoblock 参考了 Element UI 的文档渲染,实现了和它一样的,可在 Markdown 中直接编写示例的语法。

查看Demo

安装

npm install vitepress-theme-demoblock
yarn add vitepress-theme-demoblock

用法

.vitepress/config.js文件中使用demoBlockPlugin插件

markdown: {
  config: (md) => {
    const { demoBlockPlugin } = require('vitepress-theme-demoblock')
    md.use(demoBlockPlugin)
  }
}

.vitepress/theme/index.js中使用vitepress-theme-demoblock主题,并注册组件(包含主题中默认的组件)。

import theme from 'vitepress/dist/client/theme-default'
import 'vitepress-theme-demoblock/theme/styles/index.css'
import { registerComponents } from './register-components'

export default {
  ...theme,
  enhanceApp({ app, router, siteData }) {
    registerComponents(app)
  }
}

package.json配置命令scripts,vitepress-rc用来注册组件(--docsDir 指定docs目录,--componentsDir 指定组件注册目录)

"scripts": {
  "docs:dev": "yarn run register:components && vitepress dev docs",
  "docs:build": "yarn run register:components && vitepress build docs",
  "docs:serve": "vitepress serve docs",
  "register:components": "vitepress-rc"
}

多语言

.vitepress/config.js文件中增加demoblock字段来支持多语言 (默认中文)

themeConfig: {
  // demoblock locales
  demoblock: {
    '/': {
      'hide-text': 'Hide',
        'show-text': 'Expand',
          'copy-button-text': 'Copy'
    },
      '/zh': {
        'hide-text': '隐藏代码',
          'show-text': '显示代码',
            'copy-button-text': '复制代码片段'
      }
  }
}