adjust toc style

This commit is contained in:
Feng Ruohang 2025-08-09 21:25:38 +08:00
parent bb300d5bc2
commit 8acb45f596
3 changed files with 78 additions and 0 deletions

49
assets/css/custom.css Normal file
View File

@ -0,0 +1,49 @@
/* 调整左侧导航栏的宽度 */
/* 增加宽度以确保文本不换行 */
/* 左侧导航栏宽度调整 - 增加到 28rem 以避免换行 */
.hextra-sidebar {
width: 28rem !important;
min-width: 28rem !important;
}
/* 确保导航内容正确显示 */
.hextra-sidebar nav {
width: 100%;
}
/* 防止导航项文字换行 */
.hextra-sidebar li {
white-space: nowrap;
}
.sidebar-container {
width: 20rem !important;
white-space: nowrap;
}
/* 确保导航链接不换行 */
.hextra-sidebar a {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;
}
/* 调整右侧页内目录On This Page的宽度 */
/* Hextra 默认宽度约为 16rem (256px),增加 1.5 倍变为 24rem (384px) */
/* 右侧目录的宽度 */
.hextra-toc {
width: 24rem !important;
}
/* 确保目录内容正确显示 */
.hextra-toc nav {
width: 100%;
}
/* 调整目录项的文字换行以适应更宽的空间 */
.hextra-toc li {
word-wrap: break-word;
}

7
assets/css/example.css Normal file
View File

@ -0,0 +1,7 @@
.md-example { margin: 1.25rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: .75rem; }
.md-example__caption { display: flex; gap: .5rem; align-items: baseline; margin-bottom: .5rem; }
.md-example__label { font-weight: 600; opacity: .85; }
.md-example__title { font-weight: 600; }
.md-example__anchor { margin-left: auto; text-decoration: none; opacity: .6; }
.md-example__anchor:hover { opacity: 1; }
.md-example__note { margin-top: .5rem; font-size: .95em; opacity: .85; }

View File

@ -0,0 +1,22 @@
{{- $src := .Get "src" -}}
{{- $link := .Get "link" -}}
<figure
{{ with .Get "id" }}id="{{ . }}"{{ end }}
{{ with .Get "class" }}class="{{ . }}"{{ end }}
>
{{- if $src -}}
{{- with $link }}<a href="{{ . }}">{{ end -}}
<img
src="{{ $src }}"
{{ with .Get "alt" }}alt="{{ . }}"{{ end }}
{{ with .Get "width" }}width="{{ . }}"{{ end }}
{{ with .Get "height" }}height="{{ . }}"{{ end }}
/>
{{- if $link }}</a>{{ end -}}
{{- end -}}
{{ with .Get "title" }}<h4>{{ . }}</h4>{{ end }}
{{ with .Get "caption" }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
</figure>
{{- if $src }}<br />{{- end -}}