Docs: update style (#310)

Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>
This commit is contained in:
Carson Yang
2023-09-17 15:06:25 +08:00
committed by GitHub
parent 453824260f
commit 0bb31b985d
7 changed files with 322 additions and 282 deletions

View File

@@ -42,22 +42,20 @@
{{ end -}}
<!-- change -->
<div class="docs-content col-12 {{ if .IsNode }}{{ else }}{{ if site.Params.docs.toc | default true }}{{ if and (ne .Params.toc false) }}col-xl-9{{else}}{{end}}{{ else }}{{ end }}{{ end }} mt-0">
<div class="mb-3">
<div class="mb-0 d-flex">
{{ if site.Params.docs.titleIcon | default false }}
<i class="material-icons title-icon me-2">{{- .Params.icon | default "article" }}</i>
{{ end }}
<h1 class="content-title mb-0">
{{ if site.Params.docs.titleIcon | default false }}
<i class="material-icons me-0">{{- .Params.icon | default "article" }}</i>
{{ end }}
<span class="title-text">
{{ $currentPage.Title }}
</span>
{{ $currentPage.Title }}
{{ if .Draft }}
<span class="badge bg-default fs-6 mb-1 align-middle">DRAFT</span>
{{ end }}
</h1>
{{ if site.Params.docs.descriptions | default false }}
<p class="lead mb-0">{{ $currentPage.Description | markdownify }}</p>
{{ end }}
</div>
{{ if site.Params.docs.descriptions | default false }}
<p class="lead mb-3">{{ $currentPage.Description | markdownify }}</p>
{{ end }}
<div id="content" class="main-content" {{ if eq .Site.Params.docs.toc true -}}data-bs-spy="scroll" data-bs-root-margin="0px 0px -65%" data-bs-target="#toc-mobile"{{ end }}>
{{ block "main" . }}{{ end }}
</div>

View File

@@ -14,10 +14,12 @@
{{ $iconPath = "images/social/bitbucket_icon.svg" }}
{{ end }}
<!-- change -->
{{ $repoURL = $repoURL | append "docSite/content" .Site.LanguagePrefix $filePath }}
{{ $repoURL = delimit $repoURL "/" }}
{{ $editPageURL := replaceRE "(https?://)|(/)+" "$1$2" $repoURL }}
<!-- change -->
<div class="gitinfo d-flex flex-wrap justify-content-between align-items-center opacity-85 {{ if .Site.Params.docs.editPage -}}pt-3{{ else }}visually-hidden{{ end }}">
{{ if .Site.Params.docs.editPage | default false -}}
<div id="edit-this-page" class="mt-1">
@@ -28,7 +30,7 @@
{{ .Content | safeHTML }}
{{ end }}
</span>
{{ i18n "edit_page" }}
{{ i18n "edit_page" }} <!-- change -->
<!-- <span class="material-icons size-20 align-text-bottom text-primary">open_in_new</span> -->
</a>
</div>

View File

@@ -1,76 +1,105 @@
<head>
<meta charset="utf-8" />
<title>
{{- $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }} {{- if eq $url "/" }} {{-
.Site.Title }} {{- else }} {{- if .Params.heading }} {{ .Params.heading }} {{ else }} {{- if eq
.Title .Site.Title }} {{- .Title }} {{- else }} {{ .Site.Params.docs.Title | default
(.Site.Title) }} | {{ .Title }} {{- end }} {{- end }} {{- end -}}
</title>
{{- if not hugo.IsProduction }}
<meta name="robots" content="noindex" />
{{- end }}
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="A Modern Documentation Theme for Hugo" />
<meta name="keywords" content="Documentation, Hugo, Hugo Theme, Bootstrap" />
<meta name="author" content="Colin Wilson - Lotus Labs" />
<meta name="email" content="support@aigis.uk" />
<meta name="website" content="https://lotusdocs.dev" />
<meta name="Version" content="v0.1.0" />
<!-- favicon -->
{{ block "favicon" . }}{{ partialCached (printf "%s/%s" ($.Scratch.Get "pathName")
"head/favicon.html") . }}{{ end }}
<!-- 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 -}}
<script>
{
{
$darkModeInit.Content | safeJS;
}
}
</script>
{{ end -}}
<!-- FlexSearch -->
{{ if or (not (isset .Site.Params.flexsearch "enabled")) (eq .Site.Params.flexsearch.enabled true)
-}} {{ if and (.Site.Params.docsearch.appID) (.Site.Params.docsearch.apiKey) -}} {{ else }} {{
$flexSearch := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName")
"js/flexsearch.bundle.js") }} {{- if not .Site.IsServer }} {{ $flexSearch := $flexSearch | minify
| fingerprint "sha384" }}
<script
type="text/javascript"
src="{{ $flexSearch.Permalink }}"
integrity="{{ $flexSearch.Data.Integrity }}"
crossorigin="anonymous"
></script>
{{ else }}
<script type="text/javascript" src="{{ $flexSearch.Permalink }}"></script>
{{ end }} {{ end }} {{ end }}
<!-- Google Fonts -->
{{- partialCached "google-fonts" . }}
<!-- Custom CSS -->
{{- $options := dict "enableSourceMap" true }} {{- if hugo.IsProduction}} {{- $options := dict
"enableSourceMap" false "outputStyle" "compressed" }} {{- end }} {{- $style := resources.Get
(printf "/%s/%s" ($.Scratch.Get "pathName") "scss/style.scss") }} {{- $style = $style |
resources.ExecuteAsTemplate (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/style.scss") . |
resources.ToCSS $options }} {{- if hugo.IsProduction }} {{- $style = $style | minify | fingerprint
"sha384" }} {{- end -}}
<link
rel="stylesheet"
href="{{ $style.RelPermalink }}"
{{
if
hugo.IsProduction
}}integrity="{{ $style.Data.Integrity }}"
{{
end
-}}
crossorigin="anonymous"
/>
<!-- Plausible Analytics Config -->
{{- if not .Site.IsServer }} {{ if and (.Site.Params.plausible.scriptURL | default
"https://plausible.io") (.Site.Params.plausible.dataDomain) -}} {{- partialCached (printf "%s/%s"
($.Scratch.Get "pathName") "head/plausible") . }} {{- end -}} {{- end -}}
<!-- Google Analytics v4 Config -->
{{- if not .Site.IsServer }} {{- if .Site.GoogleAnalytics }} {{- template
"_internal/google_analytics.html" . -}} {{- end -}} {{- end -}}
</head>
<meta charset="utf-8" />
<title>
{{- $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
{{- if eq $url "/" }}
{{- .Site.Title }}
{{- else }}
{{- if .Params.heading }}
{{ .Params.heading }}
{{ else }}
{{- if eq .Title .Site.Title }}
{{- .Title }}
{{- else }}
{{- .Title }} | {{ .Site.Params.docs.Title | default (.Site.Title) }}
{{- end }}
{{- end }}
{{- end -}}
</title>
{{- if not hugo.IsProduction }}
<meta name="robots" content="noindex">
{{- end }}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{- with .Description | default ($.Param "description") }}
<meta name="description" content="{{ . }}">
{{- end }}
<meta name="keywords" content="Documentation, Hugo, Hugo Theme, Bootstrap" />
<meta name="author" content="Colin Wilson - Lotus Labs" />
<meta name="email" content="support@aigis.uk" />
<meta name="website" content="https://lotusdocs.dev" />
<meta name="Version" content="v0.1.0" />
<!-- favicon -->
{{ block "favicon" . }}{{ partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "head/favicon.html") . }}{{ end }}
<!-- 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 -}}
<script>{{ $darkModeInit.Content | safeJS }}</script>
{{ end -}}
<!-- FlexSearch -->
{{ if or (not (isset .Site.Params.flexsearch "enabled")) (eq .Site.Params.flexsearch.enabled true) -}}
{{ if and (.Site.Params.docsearch.appID) (.Site.Params.docsearch.apiKey) -}}
{{ else }}
{{ $flexSearch := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "js/flexsearch.bundle.js") }}
{{- if not .Site.IsServer }}
{{ $flexSearch := $flexSearch | minify | fingerprint "sha384" }}
<script type="text/javascript" src="{{ $flexSearch.Permalink }}" integrity="{{ $flexSearch.Data.Integrity }}" crossorigin="anonymous"></script>
{{ else }}
<script type="text/javascript" src="{{ $flexSearch.Permalink }}"></script>
{{ end }}
{{ end }}
{{ end }}
<!-- Google Fonts -->
{{- partialCached "google-fonts" . }}
<!-- Custom CSS -->
{{- $options := dict "enableSourceMap" true }}
{{- if hugo.IsProduction}}
{{- $options := dict "enableSourceMap" false "outputStyle" "compressed" }}
{{- end }}
{{- $style := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/style.scss") }}
{{- $style = $style | resources.ExecuteAsTemplate (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/style.scss") . | resources.ToCSS $options }}
{{- if hugo.IsProduction }}
{{- $style = $style | minify | fingerprint "sha384" }}
{{- end -}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $style.Data.Integrity }}"{{ end -}} crossorigin="anonymous">
<!-- Katex CSS -->
{{- if .Params.katex -}}
{{- $options := dict "enableSourceMap" true }}
{{- if hugo.IsProduction}}
{{- $options := dict "enableSourceMap" false "outputStyle" "compressed" }}
{{- end -}}
{{- $katexCSS := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/katex.scss") }}
{{- $katexCSS = $katexCSS | resources.ExecuteAsTemplate (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/katex.scss") . | resources.ToCSS $options }}
{{- if hugo.IsProduction }}
{{- $katexCSS = $katexCSS | minify | fingerprint "sha384" }}
{{- end -}}
<link rel="stylesheet" href="{{ $katexCSS.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $katexCSS.Data.Integrity }}"{{ end -}} crossorigin="anonymous">
{{- end -}}
<!-- Katex JS -->
{{- if .Params.katex -}}
{{ $katex := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "js/katex.js") }}
{{ $katexAutoRender := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "js/auto-render.js") }}
{{ if hugo.IsProduction }}
{{ $katex = $katex | minify | fingerprint "sha384" }}
{{ $katexAutoRender = $katexAutoRender | minify | fingerprint "sha384" }}
{{- end -}}
<script src="{{ $katex.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $katex.Data.Integrity }}"{{ end -}} defer></script>
<script src="{{ $katexAutoRender.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $katexAutoRender.Data.Integrity }}"{{ end -}} defer></script>
{{ end -}}
<!-- Katex Config -->
{{ if .Params.katex }}
{{- partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "footer/katex.html") . -}}
{{ end }}
<!-- Plausible Analytics Config -->
{{- if not .Site.IsServer }}
{{ if and (.Site.Params.plausible.scriptURL | default "https://plausible.io") (.Site.Params.plausible.dataDomain) -}}
{{- partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "head/plausible") . }}
{{- end -}}
{{- end -}}
<!-- Google Analytics v4 Config -->
{{- if not .Site.IsServer }}
{{- if .Site.GoogleAnalytics }}
{{- template "_internal/google_analytics.html" . -}}
{{- end -}}
{{- end -}}
</head>

View File

@@ -1,4 +1,5 @@
<toc>
<!-- change -->
<div class="fw-bold text-uppercase mb-2">{{ .Title }}</div>
{{ if eq .Site.Params.docs.scrollSpy true -}}
{{ .TableOfContents | replaceRE "<nav id=\"TableOfContents\">" "<nav id=\"toc\">" | safeHTML }}