From 672f8f2c32c0f14e54467fd8be7c90e6543833f7 Mon Sep 17 00:00:00 2001 From: boybook Date: Wed, 19 Mar 2025 13:40:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E7=85=A7=E6=95=99=E7=A8=8B=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=86=B3=E5=AE=9Asidebar=E7=9A=84=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=B1=95=E5=BC=80=E5=B1=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/sidebar.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/sidebar.ts b/scripts/sidebar.ts index 7bf61c3e..f98751fe 100644 --- a/scripts/sidebar.ts +++ b/scripts/sidebar.ts @@ -15,7 +15,12 @@ interface SidebarItem { // 配置参数 const DOCS_DIR = 'docs'; // 文档根目录 const IGNORE_PATHS = ['README.md', 'readme.md', 'index.md']; // 忽略的文件名 -const DEFAULT_COLLAPSED = true; // 默认折叠状态 +const DEFAULT_COLLAPSED_INDEX_MAP = { + 'wiki': 1, + 'mcdocs': 1, + 'mcguide': 0, + 'mconline': 0 +}; // 一级目录名称映射表 const CATEGORY_MAP: Record = { @@ -94,12 +99,11 @@ async function generateSidebar(): Promise> { if (!group) { const groupLink = i === 0 ? `/${segment}` : undefined; - group = { text: displayText, items: [], order, - collapsed: i < 1 ? false : DEFAULT_COLLAPSED, + collapsed: i > DEFAULT_COLLAPSED_INDEX_MAP[segments[0]], // 为目录添加活动匹配模式 activeMatch: `^/${segment}(?:/|$)`, link: groupLink