从 VitePress 迁移到主题 Press

Press 刻意保留了许多 VitePress 用户熟悉的体验,但它不是 .vitepress/config.ts 的直接替代品。

  • 将站点和主题配置迁移到 valaxy.config.tssite.config.tstheme.config.ts
  • 将内容放入 Valaxy 的 pages/ 目录。
  • 使用 Valaxy frontmatter,例如 categorieslayoutsearch
  • 通过 siteConfig.search.provider 配置搜索。
  • 需要 Algolia、Git 贡献者、评论、音乐等集成时,使用 Valaxy 插件。

常见映射

VitePressValaxy + Press
.vitepress/config.tsvalaxy.config.tssite.config.tstheme.config.ts
titledescriptionsiteConfig.titlesiteConfig.description
themeConfig.logothemeConfig.logo
themeConfig.navthemeConfig.nav
themeConfig.sidebarthemeConfig.sidebar
themeConfig.socialLinksthemeConfig.socialLinks
themeConfig.editLinkthemeConfig.editLink
themeConfig.footerthemeConfig.footer
lastUpdatedsiteConfig.lastUpdated
localesthemeConfig.localessiteConfig.languages
themeConfig.search.provider: 'local'siteConfig.search.provider: 'local'
.vitepress/theme 自定义布局/组件在 Valaxy 站点中创建同名组件覆盖
VitePress 插件Valaxy 插件,或 valaxy.config.ts 中的 Vite 插件

Press 支持 VitePress 风格的 sidebar 数组、按路径区分的多侧边栏,以及 { base, items } 对象:

valaxy.config.ts
ts
export default defineValaxyConfig<PressTheme.Config>({
  themeConfig: {
    sidebar: {
      '/guide/': {
        base: '/guide/',
        items: [
          {
            text: '指南',
            items: [
              { text: '介绍', link: '' },
              { text: '快速开始', link: 'getting-started' },
            ],
          },
        ],
      },
    },
  },
})

Valaxy 特有的补充是:顶层字符串(如 'guide')仍然会根据页面 categories 自动展开。

贡献者