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

@movk-repo/demo-preview-container

v1.1.2

Published

vitepress插件,用于预览markdown文件

Downloads

15

Readme

组件预览与展示代码 {#start}

专为增强 Markdown 文档设计,特别适用于 VueTSX 组件的实时预览与代码展示,支持自定义容器及 SSR 兼容。

✨ 特点 {#features}

  • 自定义容器:支持灵活配置容器符号和名称,满足不同文档结构的需求。
  • 组件支持:兼容 .vue.tsx 组件,轻松引入多种前端框架示例。
  • 可修改根目录:支持自定义根目录(默认 /examples),便于项目示例文件的组织和管理。
  • 简化路径管理:通过相对路径直接引入示例文件,如 /demo/test.tsx,简化路径配置。
  • SSR 兼容性:轻松使用 {ClientOnly} 选项,灵活控制组件加载方式,增强服务端渲染兼容性。
  • VitePress 扩展支持:完美支持 VitePress 的 行内语法高亮代码行号代码组 功能,提升文档的可读性和交互性。
  • 高效渲染:基于 VitePress 默认的服务端渲染机制,确保示例演示内容快速加载,提升用户体验和搜索引擎优化(SEO)。
  • 暗黑模式兼容:原生支持暗黑模式,为用户提供更好的视觉体验。

📦 安装 {#install}

| 包名 | 版本 | | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | | @movk-repo/demo-preview-plugin | | | @movk-repo/demo-preview-container | |

推荐使用 pnpm 安装,以获得更快的安装速度。

pnpm add @movk-repo/demo-preview-plugin @movk-repo/demo-preview-container

🚀 使用 {#usage}

添加插件 {#plugin}

.vitepress/config.ts 中添加插件

import { demoPreviewPlugin } from '@movk-repo/demo-preview-plugin'
import { defineConfig } from 'vitepress'

export default defineConfig({
  markdown: {
    config: (md) => {
      md.use(demoPreviewPlugin)
    },
  },
})

注册容器组件 {#container}

.vitepress/theme/index.ts 中注册容器组件

import { DemoPreviewContainer } from '@movk-repo/demo-preview-container'
import { EnhanceAppContext } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import '@movk-repo/demo-preview-container/dist/style.css'

export default {
  extends: DefaultTheme,
  async enhanceApp({ app }: EnhanceAppContext) {
    app.component('DemoPreview', DemoPreviewContainer)
  },
}

🛠️ 配置 {#config}

marker

  • 类型: string
  • 默认值: ':'

容器标记符号,用于标识容器的开始和结束。

root

  • 类型: string
  • 默认值: /examples

示例文件所在的根目录,默认值为 /examples,文件目录结构如下:

.
├─ docs
│  ├─ .vitepress
│  │  ├─ theme
│  │  │  └─ index.ts
│  │  └─ config.ts
│  └─ index.md
├─ examples
└─ package.json

name

  • 类型: string
  • 默认值: demo

自定义容器名称,用于标识容器的类型。

📝 示例

查看示例

🗓️ 更新日志

点击查看更新日志