Docs: update theme (#368)

Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>
This commit is contained in:
Carson Yang
2023-10-04 22:25:07 +08:00
committed by GitHub
parent bf172fab81
commit 7f1fecb84e
8 changed files with 56 additions and 16 deletions

View File

@@ -11,8 +11,12 @@
{{ end -}}
{{ if .Page.Store.Get "hasMermaid" }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
{{ $mermaid := resources.Get (printf "%s/%s" ($.Scratch.Get "pathName") "js/mermaid.js") }}
{{ if hugo.IsProduction }}
{{ $mermaid = $mermaid | minify | fingerprint "sha384" }}
{{ end }}
<script src="{{ $mermaid.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $mermaid.Data.Integrity }}"{{ end }}></script>
<script>
const config = {
startOnLoad:true,
logLevel: "error",

View File

@@ -30,6 +30,8 @@
<meta name="Version" content="v0.1.0" />
<!-- favicon -->
{{ block "favicon" . }}{{ partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "head/favicon.html") . }}{{ end }}
{{- partial (printf "%s/%s" ($.Scratch.Get "pathName") "head/opengraph") . }}
{{- partial (printf "%s/%s" ($.Scratch.Get "pathName") "head/twitter_cards") . }}
<!-- Dark Mode -->
{{ if eq .Site.Params.docs.darkMode true -}}
{{ $darkModeInit := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "js/darkmode-init.js") | js.Build | minify -}}

View File

@@ -42,7 +42,45 @@
<ul>
{{ range .Pages }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li class="{{ if $active }}current{{ end }} {{ if eq .Site.Params.docs.sidebarIcons true -}}{{ else }}no-icon{{ end }}"><a class="sidebar-nested-link" href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ if .IsSection }}
<li class="sidebar-dropdown nested {{ if eq .Site.Params.docs.sidebarIcons true -}}{{ else }}no-icon{{ end }} {{ if $active }}current active{{ end }}">
<button class="btn">
{{ if eq .Site.Params.docs.sidebarIcons true -}}
<!-- <span class="material-icons me-2">{{- .Params.icon }}</span> -->
{{ end }}
{{- .Title }}
</button>
<div class="sidebar-submenu {{ if $active }}d-block{{ end }}">
<ul>
{{ range .Pages }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
{{ if .IsSection }}
<li class="sidebar-dropdown nested {{ if eq .Site.Params.docs.sidebarIcons true -}}{{ else }}no-icon{{ end }} {{ if $active }}current active{{ end }}">
<button class="btn">
{{ if eq .Site.Params.docs.sidebarIcons true -}}
<!-- <span class="material-icons me-2">{{- .Params.icon }}</span> -->
{{ end }}
{{- .Title }}
</button>
<div class="sidebar-submenu {{ if $active }}d-block{{ end }}">
<ul>
{{ range .Pages }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li class="{{ if $active }}current{{ end }} {{ if eq .Site.Params.docs.sidebarIcons true -}}{{ else }}no-icon{{ end }}"><a class="sidebar-nested-link" href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
</div>
</li>
{{ else }}
<li class="{{ if $active }}current{{ end }} {{ if eq .Site.Params.docs.sidebarIcons true -}}{{ else }}no-icon{{ end }}"><a class="sidebar-nested-link" href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
</ul>
</div>
</li>
{{ else }}
<li class="{{ if $active }}current{{ end }} {{ if eq .Site.Params.docs.sidebarIcons true -}}{{ else }}no-icon{{ end }}"><a class="sidebar-nested-link" href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
</ul>
</div>