Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vitepress-for-component

dewfall123156MIT0.17.1TypeScript support: included

dumi like documentation tool

documentation, generator, vuepress, dumi, vue, vite

readme

vitepress-for-component

npm npm

VFC Fork 自VitePress,针对组件开发场景做了一些功能增强和默认样式修改。

可以理解为是一个在 VitePress 的基础上向 dumi 靠拢的工具。

详细文档.

快速开始

yarn create vlib
  • 不使用脚手架

像 vitepress 一样使用即可。

示例站点

Features

1. 内置Demo组件

我们可以在.md文件中这样来引入demo

<demo src="./demo.vue"
  language="vue"
  title="Demo演示"
  desc="这是一个Demo渲染示例">
</demo>

渲染效果如下:


demo-example

2. 像 dumi 一样的组织文件

在组件编写的场景中,我们觉得 dumi 的文件结构更合适。

示例:

假设我们有这样一个组件库。

VitePress文件结构如下。

docs
├─ index.md
├─ loading
│  └─ index.md
├─ zh
│  ├─ index.md
│  └─ loading
│     └─ index.md
src
├── loading
│ ├── demo
│ │ └── demo.vue
│ └── loading.vue
└── ...

vitepress-for-componnet文件结构如下。

docs
├── index.en-US.md
├── index.zh-CN.md
src
├── loading
│ ├── demo
│ │ └── demo.vue
│ ├── index.en-US.md
│ ├── index.zh-CN.md
│ └── loading.vue
└── ...

我们觉得dumi的组织结构有如下好处:

  • demo.vue 和 loading.md 都放在 src 下面,源码和文档联系感更强。
  • 用后缀.zh-CN来区分 locale,更加有对比度。

3. 更合适的默认样式

如图:


example

changelog

0.17.1 (2022-04-11)

0.17.0 (2022-04-11)

Bug Fixes

Features

  • more efficient useData() method that exposes all data (0661063)
  • scrollbar style (34b15ab)
  • 改用 sfc.vuejs.org (280adc1)
  • change scrollbar style (294c003)
  • exclude option (#281) (71a5e1c)
  • import code snippet with region (#237) (#238) (d1a62e1)
  • info custom container (4925fb5)
  • support ts/esm config file + defineConfig() helper (d3b1521), closes #339 #376
  • upgrade docsearch version (#441) (1b245e2)
  • upgrade vite (39a7bf7)
  • theme-default: home slot for customizing the entire homepage easily (#314) (07bf145)
  • map mode + remove deprecated options (b94b163)
  • Render titles for social sharing and improve home page sharing (#263) (e651f97)
  • support <script client> in mpa mode (e0b6997)
  • support config.extends (f749b27)
  • support function config (e74c5f0)
  • support partial include directive (7b3a9e5)
  • support passing vite config in vitepress config file via vite option (3737b10)
  • support srcDir config option (aaf4910)
  • upgrade markdown-it-anchor (#350) (26b5aa9)
  • upgrade vue, simplify deps (9030486)
  • use markdown-it-attrs for markdown-it plugins (#393) (610e9b7)

Performance Improvements

  • avoid double resolve user config on startup (5733fc6)
  • minor optimizations (96bcdda)
  • only update necessary head tags in prod (e6bb5a4)

BREAKING CHANGES

  • the markdown.anchor option is updated. Refer to valeriangalliat/markdown-it-anchor#permalinks for instructions to upgrade your existing markdown.anchor.permalink option. This doesn't affect you if you weren't changing the header permalinks behavior.
  • Some config options have changed.

    • vueOptions renamed to vue
    • alias option has been removed. Use vite.resovle.alias instead.
    • Individual useX() data methods are removed.

      // before
      import { useSiteDataByRoute, usePageData } from 'vitepress'
      const site = useSiteDataByRoute()
      const page = usePageData()
      const theme = computed(() => site.value.themeConfig)
      
      // after
      import { useData } from 'vitepress'
      const { site, page, theme } = useData()

    All destructured values are computed refs injected from app root so they are created only once globally.

    • Global mixin properties (e.g. $site) are removed. Always use useData() to retrieve VitePress data.

0.16.7 (2022-01-24)

Bug Fixes

Features

0.14.8 (2021-07-12)

0.14.6 (2021-06-30)

Bug Fixes

Features

  • 支持 less scss stylus (cac9c73)
  • logo 居中 (17f8a72)
  • outDir 基本路径改变 (c8a325e)
  • config: 使用用户自定义的 vite plugins (ee51650)

0.9.4 (2020-12-31)

0.9.3 (2020-12-31)

Bug Fixes

Features

0.3.1 (2020-10-29)

Bug Fixes

Features

0.14.8 (2021-07-12)

0.14.6 (2021-06-30)

Bug Fixes

Features

  • 支持 less scss stylus (cac9c73)
  • detect dead links (74f5ada)
  • logo 居中 (17f8a72)
  • outDir 基本路径改变 (c8a325e)
  • config: 使用用户自定义的 vite plugins (ee51650)

0.9.4 (2020-12-31)

0.9.3 (2020-12-31)

Bug Fixes

Features

0.3.1 (2020-10-29)

Bug Fixes

Features

0.12.2 (2021-02-15)

Bug Fixes

  • theme-default: avoid ad image distortion on mobile (4a40e1f)

0.12.1 (2021-02-15)

Bug Fixes

  • @ alias for import code snippet being always undefined (#204) (2aa8ab2)
  • base option not generating correct multi sidebar (#231) (#234) (a613df4)
  • ads display causing layout break in mobile view (#230) (7ceaf34)
  • home action link not being reactive (#195) (#212) (5678dc3)
  • nav home title not having locale based link (#195) (#233) (6538c8e)

0.12.0 (2021-02-09)

Bug Fixes

Features

  • add vue options config (expose @vitejs/plugin-vue) (#215) (5b34c6a)

BREAKING CHANGES

  • If sidebar option is undefined it will be treated as auto, where previsouly it looked like it was treated as false. It was always treated as auto, but due to this bug, the sidebar was hidden, therefore it looked like it was treated as false.

0.11.5 (2021-01-29)

Bug Fixes

Features

0.11.4 (2021-01-19)

  • Latest Vite beta.32 compat (internal changes).

0.11.3 (2021-01-13)

Bug Fixes

  • ignore non-html links in router and prefetch (3e6e61b)

0.11.2 (2021-01-12)

Bug Fixes

Performance Improvements

  • generate preload directives for dynamicImport chunks too (b9fc0cb)

0.11.1 (2021-01-12)

Features

  • render content on home page (ca631c7)

0.11.0 (2021-01-12)

Code Refactoring

  • move default theme to 'vitepress/theme' (a79e1e1)

Features

  • support customData in config (4072dc5)

BREAKING CHANGES

  • the default theme is now exposed via 'vitepress/theme', instead of a named export from 'vitepress'. This change fixes the case where when a completely custom theme is used, importing anything from 'vitepress' also imports the entire default theme.

0.10.8 (2021-01-11)

Bug Fixes

0.10.7 (2021-01-05)

Features

Bump to Vite 2.0.0-beta.8

Bug Fixes

0.10.6 (2021-01-04)

Bug Fixes

  • bump vite and fix win32 path resolving (#198) (da2c4f6)

0.10.5 (2021-01-02)

Bug Fixes

  • vite 2.0.0-beta.2 compat (991a443)

0.10.4 (2021-01-01)

Bug Fixes

  • ensure the same vue dep in all cases (d6b8568)
  • respect root during build (055e3fd)

0.10.3 (2021-01-01)

Bug Fixes

  • always define theme globals (8769b4b)
  • avoid unexpected vite define replacements in markdown content (a41928e)
  • loosen navLink active matching (8a2ff33)

Features

  • theme-default: nav.item.activeMatch (e262ef6)
  • add altAction for home (9a17ddf)

0.10.2 (2020-12-31)

Bug Fixes

  • adjust multi sidebar matching logic (7e4b16e)

0.10.1 (2020-12-30)

Bug Fixes

Features

Performance Improvements

  • avoid including optional features in build when not used (c878e6d)

0.10.0 (2020-12-30)

  • Upgrade to Vite 2.0

Bug Fixes

  • port fixes to parseHeader utils from vuepress (#172) (dd312ce)
  • revert datetime handling (a1daf2b)
  • style pollution on custom theme (#190) (46e99ba)
  • temporarily disable slot usage causing hydration mismatch (0239159)
  • md: avoid normalising markdown "mailto:" links (#173) (18d18d2)

0.9.2 (2020-12-10)

Fix build files

0.9.1 (2020-12-05)

Bug Fixes

Features

  • built-in ClientOnly component (8809d2d)
  • default-theme: support customLayout: true in frontmatter (f32771f)
  • add $withBase global app function (15e18df)
  • add Algolia DocSearch (#40) (#153) (5bb4730)
  • add native support for carbon ads (#86) (9d6b8ca)
  • support customizing default theme via slots (b8e892e)
  • add more global and computed properties (#152) (c6bdcfb), closes #152

0.9.0 (2020-11-24)

Bug Fixes

  • avoid 300ms click delay on touch devices (621ca3e)
  • fix nested list having too much margin (b0cf2be)
  • fix sidebar active status not working as expected (#140) (#149) (0b181e7)
  • make code block look prettier (#146) (242fcc1)
  • some color in code block not working as expected (#143) (da09266)

Features

  • add "last updated" feature (40d204b)

0.8.1 (2020-11-20)

Bug Fixes

  • fix "next and prev link" not working when link has extention (6dcf6b3)
  • fix "next and prev links" not working when the base option is set (#139) (018a9b4)

0.8.0 (2020-11-20)

Bug Fixes

  • exit process with non-zero code on error (fb09f8e)
  • fix edit link and prev and next links display (#97) (c3b7172)
  • fix next and prev links not working (#130) (fdd498b)
  • display header-anchor links when using keyboard navigation (ddc3640)
  • show top part of scrollbar in sidebar (#129) (1ba209a)

Features

0.7.4 (2020-11-11)

Bug Fixes

0.7.3 (2020-11-06)

Bug Fixes

  • Fix sidebar page switch layout shifting
  • Fix production hydration mismatch

0.7.2 (2020-11-02)

Bug Fixes

  • adapt to vite fix of ssr build asset paths (6b3fbe3)

Features

0.7.1 (2020-10-30)

Bug Fixes

  • compat with latest vite + handle no export default script tags in md (b10da2f)
  • fix switch language error (#103, #106) (#104) (d354d1e)

0.7.0 (2020-10-19)

Bug Fixes

  • css: theme specific (6891092)
  • router: remove fakeHost when fixing url extenions (2eb3135)

Features

  • client: add slot for a searchbar (68d9b18)
  • i18n: add nav dropdown language selector feature (#91) (294836c)
  • sidebar: close when navigating (2094d53)
  • add doctype html (02f2e10)
  • add some space between 2 code blocks (5daa8d2)

0.6.0 (2020-09-17)

Bug Fixes

  • client: use relative import (725a04c)
  • links: keep relative hash links as is (a90d971)
  • router: allow open new tab with ctrl + click (#69) (092ee77)
  • sidebar: no margin on mobile (#89) (218c729)
  • sidebar not working correctly when path starts with slash (610cc17)
  • sidebar: fix sidebar when you open a nested link (#73) (d2b6d39)

Features

0.5.0 (2020-07-21)

Bug Fixes

Features

0.4.1 (2020-07-02)

Bug Fixes

  • avoid error when requesting non-existing md file (e77ea63)
  • resolve relative path on windows (#27) (9116c9c)
  • use resolve instead of join (#33) (6f10ed6)

Features

0.4.0 (2020-06-19)

0.3.1 (2020-06-05)

Bug Fixes

  • avoid using DEV + throttle active header link (a63b0cf)

0.3.0 (2020-06-02)

Bug Fixes

  • lazy load @vue/server-render for production build (382e1b6)

Features

0.2.0 (2020-05-22)

Bug Fixes

  • avoid unnecessary prefetches (0a81525)
  • handle links that embed other elements (#2) (4cbfc60)

Features

Performance Improvements

  • inject script tags for page common chunk imports (57d900d)

0.1.1 (2020-04-30)

  • fix dependency versions

0.1.0 (2020-04-30)

Features

  • add markdown processing (5c47bbb)
  • spa navigation (21d3cd8)
  • update head tags during dev (bdbbdd5)
  • update title & description during dev (0b9bf27)