@evgenest/vitepress-theme-contour

中文文档
1.0.1发布于 2026/11/01MITTypeScriptES Module零依赖构建来源已验证

A VitePress 2 theme with a calmer layout, framed code blocks, a global line-wrap toggle and an auto/light/dark switch.

原始使用文档
文档目录7 节
  1. Features
  2. Install
  3. Set up
  4. Sidebar
  5. Your own markdown.config
  6. Colors
  7. License

@evgenest/vitepress-theme-contour

A theme for VitePress 2 that adds some variety to the stock look: a wider layout, framed code blocks and a few small tools for reading long code. It extends the default theme, so everything you already use in VitePress keeps working, including local search.

Requires VitePress 2, which is still in alpha. The theme styles some of VitePress's internal class names, so a new VitePress version can break parts of it. Keep your lockfile committed and look over your site after upgrading.

Features

Layout

  • Left sidebar pinned to the edge of the window, with the active page on a filled background
  • Search box and page text aligned on one line
  • A wider text column, up to 1100 px
  • The "On this page" outline hugs the right edge and takes only the width its text needs
  • A site header that stays visible while scrolling on narrow screens

Code blocks

  • Frame, higher-contrast plain text and a styled but visible scrollbar
  • Copy button that appears on hover and shows a green "Copied!" label
  • Line-wrap button: one click applies to every code block on the site and is remembered in the browser
  • Text never runs under the buttons: wrapped text flows around them, and an unwrapped first line fades out before them, then scrolls fully clear

Navigation

  • Auto / Light / Dark switch in the header on wide screens
  • Previous and next links as cards with arrows
  • On narrow screens, the outline highlights the current section and closes after you pick an item
  • sidebarTree() builds a nested sidebar from your folders
  • Interface language: English or Russian

Install

bun add -d vitepress@next @evgenest/vitepress-theme-contour

npm, pnpm and yarn work too.

Set up

.vitepress/theme/index.ts:

export { default } from '@evgenest/vitepress-theme-contour'

.vitepress/config.ts:

import { contourConfig, sidebarTree } from '@evgenest/vitepress-theme-contour/config'

export default {
  extends: contourConfig({ locale: 'en' }), // or 'ru'
  title: 'My docs',
  themeConfig: {
    sidebar: sidebarTree(),
  },
}

Sidebar

sidebarTree() turns each folder into a nested group and each Markdown file into a link. All options are optional:

sidebarTree({
  srcDir: 'docs',                    // same as srcDir in your config
  exclude: ['drafts.md'],            // paths relative to srcDir
  order: ['intro.md', 'guide'],      // listed first, the rest follow alphabetically
  titles: { 'intro.md': 'Welcome' }, // overrides the name in the menu
  rootLabel: 'Docs',                 // wraps the tree in one top-level group
  collapsed: false,
})

The menu name comes from titles, then frontmatter title, then the first # heading, then the file name.

exclude only hides a page from the menu. To leave it off the site, also add it to srcExclude.

A README.md in the root of srcDir links to /, so add rewrites: { 'README.md': 'index.md' } if you use one as your home page.

Your own markdown.config

You can set markdown.config as usual: VitePress runs it together with the theme's own, so the wrap buttons stay.

Colors

Colors are CSS variables. Override them in your own stylesheet, imported from .vitepress/theme/index.ts:

:root { --vp-c-brand-1: #0f766e; }
.dark { --vp-c-brand-1: #5eead4; }

License

MIT

版本与发布记录

@evgenest/vitepress-theme-contour 共发布 3 个版本,首次发布于 2026/11/01;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.1latest2026/11/012 天前
1.0.02026/11/012 天前
0.0.0-stage2026/11/012 天前

关于 @evgenest/vitepress-theme-contour 的常见问题

@evgenest/vitepress-theme-contour 是什么?

一个VitePress 2主题,具有更平静的布局,框架代码块,全局行换行开关和自动/亮/暗开关。

如何安装 @evgenest/vitepress-theme-contour?

在项目目录运行 npm install @evgenest/vitepress-theme-contour,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.5.0)、vitepress(^2.0.0-alpha.21)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@evgenest/vitepress-theme-contour 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@evgenest/vitepress-theme-contour 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@evgenest/vitepress-theme-contour 可以商用吗?

@evgenest/vitepress-theme-contour 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@evgenest/vitepress-theme-contour 还在维护吗?

最新版本 1.0.1 发布于 2026/11/01(2 天前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/11/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。