From f59b40a8e0ee3f4c808ab7b269667ab31c43c34e Mon Sep 17 00:00:00 2001
From: weru <fromweru@gmail.com>
Date: Sun, 09 Jul 2023 16:07:43 +0000
Subject: [PATCH] Merge branch 'master' into #114
---
layouts/_default/baseof.html | 52 +++++++++----
layouts/partials/functions/getCodeConfig.html | 1
layouts/partials/nav.html | 18 ++--
assets/js/variables.js | 6
assets/js/mode.js | 8 ++
exampleSite/go.mod | 5 -
layouts/partials/scripts/mermaid.html | 25 ++++++
assets/sass/_base.sass | 10 ++
layouts/_default/term.html | 25 ++----
/dev/null | 13 ---
layouts/partials/scripts/translations.html | 2
layouts/partials/opengraph.html | 2
exampleSite/go.sum | 42 +---------
layouts/partials/mode.html | 4
assets/sass/_mermaid.sass | 2
15 files changed, 111 insertions(+), 104 deletions(-)
diff --git a/assets/js/mode.js b/assets/js/mode.js
index 69aa92d..404797d 100644
--- a/assets/js/mode.js
+++ b/assets/js/mode.js
@@ -39,6 +39,12 @@
});
}
+function setMermaidTheme(mode) {
+ bank.setItem(mermaidThemeKey, mode);
+ let theme_input = elem('.color_choice');
+ theme_input.value = mode;
+}
+
function setUserColorMode(mode = false) {
const is_dark_mode = currentMode() == dark;
const stored_mode = bank.getItem(storageKey);
@@ -51,6 +57,8 @@
const user_mode = doc.dataset.mode;
doc.dataset.systemmode = sys_mode;
user_mode ? pickModePicture(user_mode) : false;
+
+ setMermaidTheme(user_mode);
}
setUserColorMode();
\ No newline at end of file
diff --git a/assets/js/variables.js b/assets/js/variables.js
index 1df76ed..f08fabc 100644
--- a/assets/js/variables.js
+++ b/assets/js/variables.js
@@ -1,12 +1,11 @@
'use strict';
-// global variables;
const doc = document.documentElement;
const toggle_id = 'toggle';
const show_id = 'show';
const menu = 'menu';
const active = 'active';
-// root_url must end with '/' for relative URLs to work properly
+let site_title = `{{ replace (lower site.Title) " " "-" }}`;
let root_url = '{{ strings.TrimSuffix "/" .Site.BaseURL }}/';
root_url = root_url.startsWith('http') ? root_url : window.location.origin;
@@ -37,7 +36,8 @@
const light = 'light';
const dark = 'dark';
-const storageKey = 'colorMode';
+const storageKey = `${site_title}-color-mode`;
+const mermaidThemeKey = `${site_title}-mermaid`;
const key = '--color-mode';
const mode_data = 'data-mode';
const bank = window.localStorage;
diff --git a/assets/sass/_base.sass b/assets/sass/_base.sass
index 9999b1e..98d6dd1 100644
--- a/assets/sass/_base.sass
+++ b/assets/sass/_base.sass
@@ -19,6 +19,14 @@
-webkit-text-size-adjust: 100%
font-size: 18px
+@keyframes flash
+ 0%
+ opacity: 0
+ 75%
+ opacity: 0
+ 100%
+ opacity: 1
+
body
font-family: var(--font)
background-color: var(--bg)
@@ -35,6 +43,8 @@
-moz-osx-font-smoothing: grayscale
-webkit-overflow-scrolling: touch
max-width: 1440px
+ animation: 0.67s flash ease-in
+
@media screen and (min-width: 1640px)
max-width: 1600px
diff --git a/assets/sass/_mermaid.sass b/assets/sass/_mermaid.sass
index 5950021..c175fa2 100644
--- a/assets/sass/_mermaid.sass
+++ b/assets/sass/_mermaid.sass
@@ -4,4 +4,4 @@
margin-bottom: 2.5rem
svg
margin: 0 auto
- display: block
+ display: block
\ No newline at end of file
diff --git a/exampleSite/go.mod b/exampleSite/go.mod
index 36bf785..6aeb891 100644
--- a/exampleSite/go.mod
+++ b/exampleSite/go.mod
@@ -2,7 +2,4 @@
go 1.15
-require (
- github.com/onweru/compose v0.0.0-20230530114506-a2ddf2b32939 // indirect
- github.com/rwstorer/hugo-theme-compose v0.0.0-20230705005233-e37ac6973101 // indirect
-)
+require github.com/onweru/compose v0.0.0-20230709140616-b352d2c11cd8 // indirect
diff --git a/exampleSite/go.sum b/exampleSite/go.sum
index aaf01f7..8dcaf4c 100644
--- a/exampleSite/go.sum
+++ b/exampleSite/go.sum
@@ -28,39 +28,9 @@
github.com/onweru/compose v0.0.0-20230522093958-40f93a906ddc/go.mod h1:tf1kQIBUcwJ/3mRFU5eiMrMvsDScVTK2IEFsZE3hZOc=
github.com/onweru/compose v0.0.0-20230530114506-a2ddf2b32939 h1:XVZlCIf6BUmHReHKp5bt/e4+Vy5NCypqiju/LEcCz4Y=
github.com/onweru/compose v0.0.0-20230530114506-a2ddf2b32939/go.mod h1:tf1kQIBUcwJ/3mRFU5eiMrMvsDScVTK2IEFsZE3hZOc=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611001648-0f1fb40e912e h1:EaCAVi8vhFZzgejGR5pf1MJPl+YC6SY+dgEkckbWyHc=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611001648-0f1fb40e912e/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611011250-29764d3cdc54 h1:JE41XHF80/O+LqQnc2/GmNpVUxhdnT+QaQP12TeQ4q0=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611011250-29764d3cdc54/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611013609-aeaea2852b98 h1:9pYay6P/mUgA31ANPqFQBjGI809JhN1Li/umaFeFhIE=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611013609-aeaea2852b98/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611013841-e25e31add480 h1:m+9tc/4S8keQy3IhvdtzlZf0T2rW8LIHBkTD6qS40kM=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611013841-e25e31add480/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611014843-d3652998710e h1:X7/nJFMOqLwYy0a/QPHDxQ1Mq6hJHNI+Tv8xWyBU9Bk=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611014843-d3652998710e/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611021301-f7396f1edb0b h1:y71DHDUESv7+42YRzsXdVoTxCDgvnw+I3Wrzjg9J1Mo=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611021301-f7396f1edb0b/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611022804-cdec55a13770 h1:Kl9D/nTVK2JlmwYrcT2y6yDpoMtaRLTI6mUJtwxK0tQ=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611022804-cdec55a13770/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611030846-a91f59280bbb h1:Wj03s4AZMZ2uVa6yMTDQ2SunKHsA6uh8pKRRBl6xyFc=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611030846-a91f59280bbb/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611031132-ddffdf7dde93 h1:TtzPjBvXJjWYhqPDFumnS4xDFVfAlJEXBFuuhoBK4/U=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611031132-ddffdf7dde93/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611031251-11099f76fce2 h1:tWGK7hU0ptbaehbGSlvGpJQHvSUW6ksvBD5SGKqvFWI=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611031251-11099f76fce2/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611033347-7c57127c2f46 h1:SXeF48TLLcxOMG2ZFpv2+hu9IhfrMWzPxYWEJ2UnATU=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611033347-7c57127c2f46/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611034420-6b46b885a5f3 h1:GdIR5ZgIV0OQyLBt7z7wph7ttrflg9Zu8t+URhCSMQA=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611034420-6b46b885a5f3/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611035253-44d4e6b24d65 h1:kcZ3SINPfK3QTk0cpn0j0KxSDyJWz32k9VAEbfKgc+s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611035253-44d4e6b24d65/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611040011-726a11f5e7b8 h1:lpduewP+0F23NVASVa7WJ96JNxFfWeeKUybWjFhfSac=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611040011-726a11f5e7b8/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611041900-16c2ce96ef5a h1:O5zmkIshvR3RKLwxxDhFOXz1RGvsF23KAv9MrCxBrPc=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611041900-16c2ce96ef5a/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611042716-1ae2e3d6a2af h1:XV6rJpiYMEox+r63cdP9ShXR9E2jshhiij1Ftu7I6VI=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611042716-1ae2e3d6a2af/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611043851-fa22efc00a50 h1:aAO6ExmIP513PY1Eny9ROAHMsKy2mcgH2j4Sd+gyJNU=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230611043851-fa22efc00a50/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230705005233-e37ac6973101 h1:LdUnwLgzORSs86EpkgioaHoSCNOLVZpqBBBiNECa7Ts=
-github.com/rwstorer/hugo-theme-compose v0.0.0-20230705005233-e37ac6973101/go.mod h1:7TS3BoBV/IcLPRT2r7LyTyOqzsS5P5sXKlNpGgxdK/s=
+github.com/onweru/compose v0.0.0-20230615081942-67dad4f6ef90 h1:YtZ28Fg638nbpKbvwEB16c3LBIdDxEAi8E0eWmo+Dw0=
+github.com/onweru/compose v0.0.0-20230615081942-67dad4f6ef90/go.mod h1:tf1kQIBUcwJ/3mRFU5eiMrMvsDScVTK2IEFsZE3hZOc=
+github.com/onweru/compose v0.0.0-20230709124724-5ebe0b0b8d16 h1:cMfQ9aU/j2yJYbzuytHa3TAnFryZmQtp08nDCxUnnNk=
+github.com/onweru/compose v0.0.0-20230709124724-5ebe0b0b8d16/go.mod h1:tf1kQIBUcwJ/3mRFU5eiMrMvsDScVTK2IEFsZE3hZOc=
+github.com/onweru/compose v0.0.0-20230709140616-b352d2c11cd8 h1:6D3uUi+TB00CDWbDCmWpJVjzYAy8KcCZ4a7Is36BrzI=
+github.com/onweru/compose v0.0.0-20230709140616-b352d2c11cd8/go.mod h1:tf1kQIBUcwJ/3mRFU5eiMrMvsDScVTK2IEFsZE3hZOc=
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 395c139..03e111b 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -24,22 +24,42 @@
{{ if .IsHome }}
{{ $uniqueHomepage = true }}
{{ end }}
+ <head>
+ {{- partial "head" . }}
+ </head>
+ <body class="page-{{ .Kind }}" id="pagetop">
+ <header class="nav_header">
+ {{- partial "nav" . }}
+ </header>
+ {{ if or (eq .Section site.Params.blogDir) (eq .Type "search" ) }}
+ {{- block "main" . }}{{ end }}
{{ else }}
- {{ $uniqueHomepage = false }}
+ <div class="main wrap pt-4">
+ {{ $docSections := site.Params.docSections }}
+ {{- with $docSections }}{{- else }}
+ {{- $docSections = "docs" }}
+ {{- end }}
+ {{ $uniqueHomepage := .IsHome }}
+ {{ if site.Params.uniqueHomepage }}
+ {{ if .IsHome }}
+ {{ $uniqueHomepage = true }}
+ {{ end }}
+ {{ else }}
+ {{ $uniqueHomepage = false }}
+ {{ end }}
+ {{- if and (in $docSections .Section) (ne $uniqueHomepage true) }}
+ {{- partial "document" . }}
+ {{- else }}
+ <div class="content">
+ {{- block "main" . }}{{ end }}
+ </div>
+ {{- end -}}
+ </div>
{{ end }}
- {{- if and (in $docSections .Section) (ne $uniqueHomepage true) }}
- {{- partial "document" . }}
- {{- else }}
- <div class="content">
- {{- block "main" . }}{{ end }}
- </div>
- {{- end -}}
- </div>
- {{ end }}
- {{- partial "scripts/translations" . -}}
- {{- partialCached "footer" . -}}
- {{- partialCached "sprites" . -}}
- {{- partial "scripts/bundle" . -}}
- {{- partial "scripts/other" . -}}
-</body>
+ {{- partial "scripts/translations" . -}}
+ {{- partialCached "footer" . -}}
+ {{- partialCached "sprites" . -}}
+ {{- partial "scripts/bundle" . -}}
+ {{- partial "scripts/mermaid" . -}}
+ </body>
</html>
diff --git a/layouts/_default/term.html b/layouts/_default/term.html
index e81b969..3034006 100644
--- a/layouts/_default/term.html
+++ b/layouts/_default/term.html
@@ -1,7 +1,7 @@
{{ define "main" }}
{{- $pages := .Data.Pages }}
{{ .Data.Terms }}
-<div class = 'wrap pt-2 mt-2'>
+<div class="wrap pt-2 mt-2">
{{- $paginator := .Paginate $pages -}}
{{- $size := $paginator.PageSize }}
{{- $scratch := newScratch }}
@@ -16,27 +16,20 @@
{{- if in $image "https://" }}
{{- $bg = $image }}
{{- end }}
- <article class = 'article mb-2'>
- <a href = '{{ $value.Permalink }}' {{ if eq $index 0 }} class = 'grid-reverse' {{ end }}>
- <div class = 'article_thumb' style='background-image: url({{ $bg }})'></div>
- <div class = 'article_meta {{ if eq $index 0 }} center_y {{ end }}'>
- <time class = 'post_date'>{{ dateFormat "January 02, 2006" $value.Date }}</time>
- <h3 class = 'article_title'>{{ $value.Title }}</h3>
- <div class = 'article_excerpt {{ if eq $index 0 }} visible {{ end }}'>
+ <article class="article mb-2">
+ <a href="{{ $value.Permalink }}" {{ if eq $index 0 }} class=grid-reverse {{ end }}>
+ <div class="article_thumb" style="background-image: url({{ $bg }})"></div>
+ <div class="article_meta {{ if eq $index 0 }} center_y {{ end }}">
+ <time class="post_date">{{ dateFormat "January 02, 2006" $value.Date }}</time>
+ <h3 class="article_title">{{ $value.Title }}</h3>
+ <div class="article_excerpt {{ if eq $index 0 }} visible {{ end }}">
<p>{{ $value.Summary | truncate 100 }}</p>
</div>
</div>
</a>
</article>
- {{- if and (eq $index 0) (gt $size 1) }}<div class = 'grid-2 article_showcase'>{{ end }}
+ {{- if and (eq $index 0) (gt $size 1) }}<div class="grid-2 article_showcase">{{ end }}
{{- if and (eq $index (add $size -1)) (gt $size 1) }}</div>{{ end }}
{{- end }}
</div>
-<!-- <a href = '{{ absURL (printf "post/%s" "") }}' class = 'post_nav'>
- <span class = 'post_next'>View Archive
- <svg class="icon icon_scale">
- <use xlink:href="#double-arrow"></use>
- </svg>
- </span>
-</a> -->
{{ end }}
diff --git a/layouts/partials/functions/getCodeConfig.html b/layouts/partials/functions/getCodeConfig.html
index 2c30dc8..a2388b0 100644
--- a/layouts/partials/functions/getCodeConfig.html
+++ b/layouts/partials/functions/getCodeConfig.html
@@ -1,4 +1,3 @@
-<!-- will return an array holding 1) Whether to show line numbers or not 2) maximum number of lines per code block -->
{{- $s := site.Params }}
{{- $p := .Params }}
{{- $maxCodeLines := default 100 $s.codeMaxLines }}
diff --git a/layouts/partials/mode.html b/layouts/partials/mode.html
index bcf4b69..cf2ffc0 100644
--- a/layouts/partials/mode.html
+++ b/layouts/partials/mode.html
@@ -1,4 +1,4 @@
-<div class="color_mode">
- <label for="mode"></label>
+<div class=color_mode>
+ <label for=mode></label>
<input type="checkbox" class="color_choice standardize-input" id="mode" title="Toggle Dark Mode">
</div>
diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html
index 7becffa..c4efcf1 100644
--- a/layouts/partials/nav.html
+++ b/layouts/partials/nav.html
@@ -1,4 +1,4 @@
-{{- $s := .Site }}
+{{- $s := site }}
{{- $sp := $s.Params }}
<nav class="wrap nav menu">
<a href='{{ absLangURL "" }}' class="nav_brand">
@@ -31,19 +31,19 @@
</li>
{{- end }}
{{ $repo := $sp.source }}
+ {{ with $sp.source }}
<li class="nav-item nav_repo">
- <a class="nav-link" href="{{ $repo.url }}" target="_blank">
- {{ if $repo.iconLight }}
- {{- $litPath := absURL ($repo.iconLight) }}
- {{- $darkPath := absURL ($repo.iconDark) }}
+ <a class="nav-link" href="{{ .url }}" target="_blank">
+ {{ if .iconLight }}
+ {{- $litPath := absURL .iconLight }}
+ {{- $darkPath := absURL .iconDark }}
<picture data-lit="{{ $litPath }}" data-dark="{{ $darkPath }}">
- <img src="{{ $litPath }}" alt="{{ $repo.name }} Repo">
+ <img src="{{ $litPath }}" alt="{{ .name }} Repo">
</picture>
- {{ else }}
- {{ $repo.name }}
- {{ end }}
+ {{ else }}{{ .name }}{{ end }}
</a>
</li>
+ {{ end }}
<li class="nav-item">{{ partial "mode" . }}</li>
</ul>
</nav>
diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html
index 3173936..9b47eba 100644
--- a/layouts/partials/opengraph.html
+++ b/layouts/partials/opengraph.html
@@ -1,6 +1,6 @@
{{- template "_internal/opengraph.html" . -}}
{{- template "_internal/schema.html" . -}}
{{- template "_internal/twitter_cards.html" . -}}
-{{- if eq (getenv "HUGO_ENV") "production" }}
+{{- if hugo.IsProduction }}
{{- template "_internal/google_analytics.html" . }}
{{- end }}
diff --git a/layouts/partials/scripts/mermaid.html b/layouts/partials/scripts/mermaid.html
new file mode 100644
index 0000000..0ae5df8
--- /dev/null
+++ b/layouts/partials/scripts/mermaid.html
@@ -0,0 +1,25 @@
+
+{{ if in .Content "mermaid" }}
+<script type="module">
+ import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
+ let theme_input = elem('.color_choice');
+ let key = theme_input.value;
+
+ function getTheme(mode) {
+ return key == 'dark' ? 'dark' : 'base';
+ }
+
+ function initializeMermaid(mode) {
+ mermaid.initialize(
+ { startOnLoad: true, theme: getTheme(mode) }
+ );
+ }
+
+ initializeMermaid(key);
+
+ theme_input.addEventListener('change', e => {
+ location.reload();
+ initializeMermaid(e.target.value);
+ });
+</script>
+{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/scripts/other.html b/layouts/partials/scripts/other.html
deleted file mode 100644
index ee25a42..0000000
--- a/layouts/partials/scripts/other.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-{{ if in .Content "mermaid" }}
-<input type="checkbox" class="mermaid-theme">
-<script type="module">
- import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
-
- function initialize_mermaid(theme = 'base') {
- mermaid.initialize({ startOnLoad: true, theme: theme });
- }
-
- initialize_mermaid();
-</script>
-{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/scripts/translations.html b/layouts/partials/scripts/translations.html
index a482640..52afcb0 100644
--- a/layouts/partials/scripts/translations.html
+++ b/layouts/partials/scripts/translations.html
@@ -6,8 +6,6 @@
const toggle_line_wrap_text = '{{ T "toggle_line_wrap" }}';
const resize_snippet = '{{ T "resize_snippet" }}';
const not_set = '{{ T "not_set" }}';
-
-// defined in i18n / translation files
const quick_links = '{{ T "quick_links" }}';
const search_results_label = '{{ T "search_results_label" }}';
const short_search_query = '{{ T "short_search_query" }}'
--
Gitblit v1.10.0