Warm tip: This article is reproduced from serverfault.com, please click

vue.js-VuePress:Exery 单页侧边栏中的自定义内容

(vue.js - VuePress : Custom Contents in Sidebar for Exery Single Page)

发布于 2021-08-01 14:50:43

我希望每个页面都有自定义链接和不同的侧边栏我不希望我的标题呈现为侧边栏中的目录我希望有这样的自定义内容。

Node JS
-Lecture 1 Introduction
--Sub Lecture

-Lecture 2 Basics
--Sub Lecture
---Nested Lecture

所有讲座都是自定义链接。那我该怎么做。

Questioner
I'm Beginner
Viewed
0
I'm Beginner 2021-08-07 20:32:12

侧边栏

  • 类型:false | 'auto' | SidebarConfigArray | SidebarConfigObject

  • 默认:'auto'

  • 细节:

    侧边栏的配置。

    你可以通过页面中的侧边栏 frontmatter 覆盖此全局选项。

    设置false为禁用侧边栏。

    如果将其设置为'auto',则侧边栏将从页眉中自动生成。

    要手动配置侧边栏项目,你可以将此选项设置为侧边栏数组,其中每个项目可以是SidebarItem对象或字符串:

    • 一个SidebarItem对象应该有一个text字段,可以有一个可选link字段和一个可选children字段。children字段应该是一个侧边栏数组
    • 字符串应该是目标页面文件的路径。它将被转换为一个SidebarItem对象,该对象text是页面标题,link是页面路由路径,并且children是从页面标题自动生成的。

    如果要为不同的子路径设置不同的侧边栏,可以将此选项设置为侧边栏对象

    • 键应该是路径前缀。
    • 该值应该是一个侧边栏数组
  • 为了在外部和内部添加自定义链接,请参见:

module.exports = {
  themeConfig: {
    // sidebar object
    // pages under different sub paths will use different sidebar
    sidebar: {
      '/guide/': [
        {
          text: 'Guide',
          children: ['/guide/README.md', '/guide/getting-started.md'],
        },
      ],
      '/reference/': [
        {
          text: 'Reference',
          children: ['/reference/cli.md', '/reference/config.md'],
        },
      ],
    },
  },
}

有关更多信息,请参阅侧边栏配置