From 9b5f3fad7068298265dbbc8a65077f7917a090a5 Mon Sep 17 00:00:00 2001 From: aethrvmn Date: Sun, 21 Sep 2025 00:27:35 +0200 Subject: updated hugo-book theme --- themes/hugo-book/layouts/_shortcodes/badge.html | 5 +++++ themes/hugo-book/layouts/_shortcodes/button.html | 5 +++++ themes/hugo-book/layouts/_shortcodes/card.html | 22 ++++++++++++++++++++++ themes/hugo-book/layouts/_shortcodes/columns.html | 21 +++++++++++++++++++++ themes/hugo-book/layouts/_shortcodes/details.html | 7 +++++++ themes/hugo-book/layouts/_shortcodes/hint.html | 3 +++ themes/hugo-book/layouts/_shortcodes/html.html | 1 + themes/hugo-book/layouts/_shortcodes/i18n.html | 2 ++ themes/hugo-book/layouts/_shortcodes/image.html | 12 ++++++++++++ themes/hugo-book/layouts/_shortcodes/katex.html | 19 +++++++++++++++++++ themes/hugo-book/layouts/_shortcodes/mermaid.html | 12 ++++++++++++ themes/hugo-book/layouts/_shortcodes/section.html | 13 +++++++++++++ themes/hugo-book/layouts/_shortcodes/steps.html | 3 +++ themes/hugo-book/layouts/_shortcodes/tab.html | 9 +++++++++ themes/hugo-book/layouts/_shortcodes/tabs.html | 3 +++ 15 files changed, 137 insertions(+) create mode 100644 themes/hugo-book/layouts/_shortcodes/badge.html create mode 100644 themes/hugo-book/layouts/_shortcodes/button.html create mode 100644 themes/hugo-book/layouts/_shortcodes/card.html create mode 100644 themes/hugo-book/layouts/_shortcodes/columns.html create mode 100644 themes/hugo-book/layouts/_shortcodes/details.html create mode 100644 themes/hugo-book/layouts/_shortcodes/hint.html create mode 100644 themes/hugo-book/layouts/_shortcodes/html.html create mode 100644 themes/hugo-book/layouts/_shortcodes/i18n.html create mode 100644 themes/hugo-book/layouts/_shortcodes/image.html create mode 100644 themes/hugo-book/layouts/_shortcodes/katex.html create mode 100644 themes/hugo-book/layouts/_shortcodes/mermaid.html create mode 100644 themes/hugo-book/layouts/_shortcodes/section.html create mode 100644 themes/hugo-book/layouts/_shortcodes/steps.html create mode 100644 themes/hugo-book/layouts/_shortcodes/tab.html create mode 100644 themes/hugo-book/layouts/_shortcodes/tabs.html (limited to 'themes/hugo-book/layouts/_shortcodes') diff --git a/themes/hugo-book/layouts/_shortcodes/badge.html b/themes/hugo-book/layouts/_shortcodes/badge.html new file mode 100644 index 0000000..0bbfcb1 --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/badge.html @@ -0,0 +1,5 @@ +{{- $style := default "default" (.Get "style") -}} + + {{- with .Get "title" }}{{ . | plainify }}{{ end -}} + {{- with .Get "value" }}{{ . | plainify }}{{ end -}} + \ No newline at end of file diff --git a/themes/hugo-book/layouts/_shortcodes/button.html b/themes/hugo-book/layouts/_shortcodes/button.html new file mode 100644 index 0000000..cd7e016 --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/button.html @@ -0,0 +1,5 @@ +{{ $href := partial "docs/links/portable-link" (dict "Page" .Page "Destination" (.Get "href")) -}} +{{ $isRemote := (urls.Parse $href).Scheme}} + + {{- .InnerDeindent -}} + diff --git a/themes/hugo-book/layouts/_shortcodes/card.html b/themes/hugo-book/layouts/_shortcodes/card.html new file mode 100644 index 0000000..086fb97 --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/card.html @@ -0,0 +1,22 @@ +{{- /* remove whitespace */ -}} +{{- with .Get "href" -}} +{{- $destination := partial "docs/links/portable-link" (dict "Page" $.Page "Destination" .) -}} + +{{- template "book-card-content" $ -}} + +{{- else -}} +
+{{- template "book-card-content" $ -}} +
+{{- end -}} + +{{- define "book-card-content" -}} +{{- with .Get "image" -}} + {{- $destination := partial "docs/links/portable-image" (dict "Page" $.Page "Destination" .) -}} + +{{- end }} +
+ {{ with .InnerDeindent }}{{ . }}{{ end }} +
+{{- end -}} +{{- /* remove whitespace */ -}} diff --git a/themes/hugo-book/layouts/_shortcodes/columns.html b/themes/hugo-book/layouts/_shortcodes/columns.html new file mode 100644 index 0000000..1d6abdd --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/columns.html @@ -0,0 +1,21 @@ +{{- $ratio := (split (.Get "ratio") ":") -}} +{{- if strings.Contains .InnerDeindent "<--->" -}} +{{ warnf "Columns shortcode seprator '<--->' is deprecated, use markdown list instead." -}} +
+{{ range $index, $content := split .InnerDeindent "<--->" }} + {{- $grow := default 1 (index $ratio $index) -}} +
+ {{ $content | safeHTML }} +
+{{ end }} +
+{{ else }} +{{- if .Get "ratio" }}{{ end -}} +
+{{ .InnerDeindent | safeHTML }} +
+{{ end -}} diff --git a/themes/hugo-book/layouts/_shortcodes/details.html b/themes/hugo-book/layouts/_shortcodes/details.html new file mode 100644 index 0000000..a80209b --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/details.html @@ -0,0 +1,7 @@ +
+ {{- $summary := cond .IsNamedParams (.Get "title") (.Get 0) -}} + {{ $summary }} +
+ {{ .InnerDeindent | safeHTML }} +
+
diff --git a/themes/hugo-book/layouts/_shortcodes/hint.html b/themes/hugo-book/layouts/_shortcodes/hint.html new file mode 100644 index 0000000..a71f1fd --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/hint.html @@ -0,0 +1,3 @@ +
+ {{ .Inner | safeHTML }} +
diff --git a/themes/hugo-book/layouts/_shortcodes/html.html b/themes/hugo-book/layouts/_shortcodes/html.html new file mode 100644 index 0000000..b447d45 --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/html.html @@ -0,0 +1 @@ +{{- .Inner | safeHTML -}} \ No newline at end of file diff --git a/themes/hugo-book/layouts/_shortcodes/i18n.html b/themes/hugo-book/layouts/_shortcodes/i18n.html new file mode 100644 index 0000000..b65f70a --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/i18n.html @@ -0,0 +1,2 @@ +{{- $content := .Get 0 -}} +{{- default $content (i18n $content) -}} \ No newline at end of file diff --git a/themes/hugo-book/layouts/_shortcodes/image.html b/themes/hugo-book/layouts/_shortcodes/image.html new file mode 100644 index 0000000..e1b9c46 --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/image.html @@ -0,0 +1,12 @@ +{{- /* remove whitespaces */ -}} +{{- $destination := partial "docs/links/portable-image" (dict "Page" .Page "Destination" (.Get "src")) -}} + +{{- /* remove whitespaces */ -}} \ No newline at end of file diff --git a/themes/hugo-book/layouts/_shortcodes/katex.html b/themes/hugo-book/layouts/_shortcodes/katex.html new file mode 100644 index 0000000..b3f38ac --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/katex.html @@ -0,0 +1,19 @@ +{{- if not (.Page.Store.Get "katex") -}} + + + +{{ with resources.Get "katex.json" }} + +{{ end }} +{{- .Page.Store.Set "katex" true -}} +{{- end -}} + +{{ if .Inner }} + + {{- if .Get "display" }} + \[ {{ .Inner }} \] + {{ else }} + \( {{ .Inner }} \) + {{ end -}} + +{{ end }} diff --git a/themes/hugo-book/layouts/_shortcodes/mermaid.html b/themes/hugo-book/layouts/_shortcodes/mermaid.html new file mode 100644 index 0000000..078d7d3 --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/mermaid.html @@ -0,0 +1,12 @@ +{{ if not (.Page.Store.Get "mermaid") }} + + +{{ with resources.Get "mermaid.json" }} + +{{ end }} +{{ .Page.Store.Set "mermaid" true }} +{{ end }} + +
+  {{- .Inner | htmlEscape | safeHTML  -}}
+
diff --git a/themes/hugo-book/layouts/_shortcodes/section.html b/themes/hugo-book/layouts/_shortcodes/section.html new file mode 100644 index 0000000..b700ec4 --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/section.html @@ -0,0 +1,13 @@ +{{- warnf "Section shortcode is deprecated and will be removed" -}} +
+{{ range .Page.Pages }} +
+ {{ partial "docs/title" . }} +
+ {{ if (in $.Params "summary") -}} +
+ {{ default .Summary .Description }} +
+ {{ end -}} +{{ end }} +
diff --git a/themes/hugo-book/layouts/_shortcodes/steps.html b/themes/hugo-book/layouts/_shortcodes/steps.html new file mode 100644 index 0000000..46cfaa1 --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/steps.html @@ -0,0 +1,3 @@ +
+ {{ .Inner }} +
\ No newline at end of file diff --git a/themes/hugo-book/layouts/_shortcodes/tab.html b/themes/hugo-book/layouts/_shortcodes/tab.html new file mode 100644 index 0000000..b5a753d --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/tab.html @@ -0,0 +1,9 @@ +{{- $group := printf "tabs-%v" (default .Parent.Ordinal (.Parent.Get 0)) -}} +{{- $tab := printf "%s-%d" $group .Ordinal }} + + +
+ {{- .Inner -}} +
diff --git a/themes/hugo-book/layouts/_shortcodes/tabs.html b/themes/hugo-book/layouts/_shortcodes/tabs.html new file mode 100644 index 0000000..fecbbeb --- /dev/null +++ b/themes/hugo-book/layouts/_shortcodes/tabs.html @@ -0,0 +1,3 @@ +
+{{ .Inner }} +
-- cgit v1.2.3