add side class for toc if TocSide is true

This commit is contained in:
Reorx 2022-04-09 23:59:22 +08:00
parent 8c5d10925e
commit 60f139d529
2 changed files with 11 additions and 6 deletions

View File

@ -263,20 +263,25 @@
border-radius: var(--radius);
padding: 0.4em;
}
@media screen and (min-width: 1000px) {
.toc.side {
position: fixed;
right: 50px;
top: 100px;
width: 300px;
font-size: .9em;
}
}
.dark .toc {
background: var(--entry);
}
.toc details summary {
cursor: zoom-in;
cursor: pointer;
margin-inline-start: 20px;
}
.toc details[open] summary {
cursor: zoom-out;
}
.toc .details {
display: inline;
font-weight: 500;

View File

@ -1,7 +1,7 @@
{{- $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content -}}
{{- $has_headers := ge (len $headers) 1 -}}
{{- if $has_headers -}}
<div class="toc">
<div class="toc{{- if (.Param "TocSide") -}}{{- print " side" -}}{{- end -}}">
<details {{if (.Param "TocOpen") }} open{{ end }}>
<summary accesskey="c" title="(Alt + C)">
<span class="details">{{- i18n "toc" | default "Table of Contents" }}</span>