From 8b8510b27bc48ae69f23cba35b439287fdeaba64 Mon Sep 17 00:00:00 2001 From: leoli Date: Tue, 14 May 2024 17:27:45 +0800 Subject: [PATCH 1/4] added 'Context' parameter to handle relative image paths based on the current page --- layouts/about/list.html | 2 +- layouts/authors/single.html | 2 +- layouts/blog/single.html | 2 +- layouts/partials/components/author-card.html | 2 +- layouts/partials/components/blog-card.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/layouts/about/list.html b/layouts/about/list.html index b338f21..8205241 100644 --- a/layouts/about/list.html +++ b/layouts/about/list.html @@ -3,7 +3,7 @@
- {{ partial "image" (dict "Src" .Params.image "Alt" .Title "Class" "mx-auto mb-6" "Size" "200x200") }} + {{ partial "image" (dict "Src" .Params.image "Context" .Page "Alt" .Title "Class" "mx-auto mb-6" "Size" "200x200") }}

{{ .Title }}

{{ .Content }}
diff --git a/layouts/authors/single.html b/layouts/authors/single.html index 36cd1b0..18c3601 100755 --- a/layouts/authors/single.html +++ b/layouts/authors/single.html @@ -6,7 +6,7 @@
{{ $image:= .Params.image }} {{ if $image }} - {{ partial "image" (dict "Src" $image "Alt" .Title "Class" "mx-auto" "Size" "200x200") }} + {{ partial "image" (dict "Src" $image "Context" .Page "Alt" .Title "Class" "mx-auto" "Size" "200x200") }} {{ else if .Params.Email }} - {{ partial "image" (dict "Src" $image "Alt" .Title "Class" "w-full rounded") }} + {{ partial "image" (dict "Src" $image "Context" .Page "Alt" .Title "Class" "w-full rounded") }}
{{ end }}

diff --git a/layouts/partials/components/author-card.html b/layouts/partials/components/author-card.html index 23988af..f28f6d5 100755 --- a/layouts/partials/components/author-card.html +++ b/layouts/partials/components/author-card.html @@ -2,7 +2,7 @@ class="bg-theme-light dark:bg-darkmode-theme-light rounded p-8 text-center"> {{ $image:= .Params.image }} {{ if $image }} - {{ partial "image" (dict "Src" $image "Alt" .Title "Class" "mx-auto mb-6 rounded" "size" "120x120") }} + {{ partial "image" (dict "Src" $image "Context" .Page "Alt" .Title "Class" "mx-auto mb-6 rounded" "size" "120x120") }} {{ else if .Params.Email }} {{ $image:= .Params.image }} {{ if $image }} - {{ partial "image" (dict "Src" $image "Alt" .Title "Class" "mb-6 w-full rounded") }} + {{ partial "image" (dict "Src" $image "Context" .Page "Alt" .Title "Class" "mb-6 w-full rounded") }} {{ end }}

From 918f46c657cd2f5e14a0ea77174bf89f0eacb9aa Mon Sep 17 00:00:00 2001 From: leoli Date: Tue, 14 May 2024 17:32:31 +0800 Subject: [PATCH 2/4] added hugo module: mermaid --- exampleSite/config/_default/module.toml | 3 +++ exampleSite/config/_default/params.toml | 4 ++++ exampleSite/go.mod | 1 + layouts/partials/essentials/head.html | 3 +++ 4 files changed, 11 insertions(+) diff --git a/exampleSite/config/_default/module.toml b/exampleSite/config/_default/module.toml index 39ccf30..39cb6b4 100644 --- a/exampleSite/config/_default/module.toml +++ b/exampleSite/config/_default/module.toml @@ -94,3 +94,6 @@ path = "github.com/gethugothemes/hugo-modules/seo-tools/google-tag-manager" # [[imports]] # path = "github.com/gethugothemes/hugo-modules/seo-tools/counter-analytics" + +[[imports]] +path = "github.com/hugomods/mermaid" diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index c7786cd..0992553 100755 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -85,6 +85,10 @@ expire_days = 60 content = "This site uses cookies. By continuing to use this website, you agree to their use." button = "I Accept" +# diagrams +[mermaid] +js_url = 'https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.esm.min.mjs' + ######################## sidebar widgets ######################### [widgets] sidebar = ["categories", "tags"] diff --git a/exampleSite/go.mod b/exampleSite/go.mod index 6879b04..3380dfb 100644 --- a/exampleSite/go.mod +++ b/exampleSite/go.mod @@ -26,4 +26,5 @@ require ( github.com/gethugothemes/hugo-modules/tab v0.0.0-20240504032439-79fc09d96848 // indirect github.com/gethugothemes/hugo-modules/table-of-contents v0.0.0-20240504032439-79fc09d96848 // indirect github.com/gethugothemes/hugo-modules/videos v0.0.0-20240504032439-79fc09d96848 // indirect + github.com/hugomods/mermaid v0.1.1 // indirect ) diff --git a/layouts/partials/essentials/head.html b/layouts/partials/essentials/head.html index a14796b..bb7b1a7 100755 --- a/layouts/partials/essentials/head.html +++ b/layouts/partials/essentials/head.html @@ -56,3 +56,6 @@ {{/* {{ partialCached "crisp-chat.html" . }} */}} + + +{{ partial "mermaid/assets/js" . }} From eda7a9289d459fdd86b5a20758e9f172ff2aae17 Mon Sep 17 00:00:00 2001 From: leoli Date: Tue, 14 May 2024 17:35:31 +0800 Subject: [PATCH 3/4] added table of contents to blog single page --- layouts/blog/single.html | 1 + 1 file changed, 1 insertion(+) diff --git a/layouts/blog/single.html b/layouts/blog/single.html index 1290dc0..8ec1348 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -41,6 +41,7 @@
+ {{ partial "toc.html" (dict "Class" "blog" "Collapsed" false "TableOfContents" .TableOfContents ) }} {{ .Content }}
From 7d53f5da15c5a1088daa3cdc4e275f5f488e7081 Mon Sep 17 00:00:00 2001 From: leoli Date: Wed, 15 May 2024 19:39:26 +0800 Subject: [PATCH 4/4] add mermaid flowchart to elements page --- exampleSite/content/english/pages/elements.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/exampleSite/content/english/pages/elements.md b/exampleSite/content/english/pages/elements.md index 269ddbb..0734549 100755 --- a/exampleSite/content/english/pages/elements.md +++ b/exampleSite/content/english/pages/elements.md @@ -192,6 +192,15 @@ s = "Python syntax highlighting" print s ``` +```mermaid +flowchart TD + A[Start] --> B{Is it?} + B -- Yes --> C[OK] + C --> D[Rethink] + D --> B + B -- No ----> E[End] +``` +
### Blockquote