惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
M
MIT News - Artificial intelligence
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
N
Netflix TechBlog - Medium
G
Google Developers Blog
L
LangChain Blog
腾讯CDC
大猫的无限游戏
大猫的无限游戏
U
Unit 42
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
The GitHub Blog
The GitHub Blog
博客园_首页
GbyAI
GbyAI

Hyde Blog

Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog
Hyde Blog
Hyde · 2025-10-05 · via Hyde Blog

自动生成的侧边栏 ​

1.修改 docusaurus.config.js 文件 ​

打开 docusaurus.config.js 文件,并在 themeConfig 中配置 sidebar 的属性。你可以将自动生成的侧边栏配置与可折叠和隐藏功能结合起来。

  • 具体配置如下:

ts

module.exports = {
  themeConfig: {
    docs: {
      sidebar: {
        // 允许隐藏侧边栏
        hideable: true,
        // 启用自动折叠类别
        autoCollapseCategories: true,
      },
    },
    navbar: {
      ...
    },
    // 引用自动生成的侧边栏配置
    // highlight-next-line
    sidebar: require('./sidebars.ts'),
  },
};

确保你的 sidebars.ts 文件中正确配置了自动生成的侧边栏。例如:

ts

import type { SidebarsConfig } from "@docusaurus/plugin-content-docs";

const sidebars: SidebarsConfig = {
  // highlight-start
  mySidebar: [
    {
      type: "autogenerated",
      dirName: ".",
    },
  ], // 自动生成侧边栏
  // highlight-end
};

module.exports = sidebars;

通过以上配置,你可以实现自动生成侧边栏,并且支持侧边栏的隐藏和类别的自动折叠。这样能够提升用户在导航大量文档时的体验