Skip to content

Commit

Permalink
Change siderbar style
Browse files Browse the repository at this point in the history
  • Loading branch information
ihavecoke committed Jun 4, 2024
1 parent 54826c8 commit 655ac37
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
21 changes: 18 additions & 3 deletions .vitepress/theme/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ ol {
@apply absolute;
}

p, ul, ol {
p,
ul,
ol {
margin-top: 0;
}

Expand Down Expand Up @@ -160,6 +162,14 @@ ol {
font-weight: normal;
color: var(--vp-c-text-2) !important;
}

.VPSidebarItem.level-1.is-active > .item .text,
.VPSidebarItem.level-2.is-active > .item .text,
.VPSidebarItem.level-3.is-active > .item .text,
.VPSidebarItem.level-4.is-active > .item .text,
.VPSidebarItem.level-5.is-active > .item .text {
color: var(--vp-c-brand-1) !important;
}
}
.VPSidebarItem.level-0 {
.VPLink {
Expand All @@ -183,7 +193,8 @@ ol {
@apply mt-5;
}

ul, ol {
ul,
ol {
li > p {
margin: 0;
}
Expand All @@ -200,7 +211,7 @@ ol {
margin: 0;
line-height: 1.7;
}

table tr td {
vertical-align: top;
}
Expand All @@ -215,3 +226,7 @@ ol {
.DocSearch-Button {
border-color: var(--vp-c-divider);
}

.vp-doc a {
font-weight: normal;
}
11 changes: 9 additions & 2 deletions scripts/siderbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ function generateSidebarConfig(metaData, locale = "zh-HK") {

if (doc.has_child) {
sidebarItem.items = generateSidebarConfig(doc.children, locale);
// not collapsed if depth = 1
sidebarItem.collapsed = doc.depth !== 1;
// 特殊处理 “常见问题” 节点数据,默认折叠显示
if (
doc.parent_node_token === "JIl7wbv6ViOo7IkpuVrcH8GEnKe" ||
doc.node_token === "JIl7wbv6ViOo7IkpuVrcH8GEnKe"
) {
sidebarItem.collapsed = true;
} else {
sidebarItem.collapsed = doc.depth > 2;
}
}

sidebarConfig.push(sidebarItem);
Expand Down

0 comments on commit 655ac37

Please sign in to comment.