summaryrefslogtreecommitdiff
path: root/themes/hugo-book/layouts/_shortcodes
diff options
context:
space:
mode:
authoraethrvmn <me@aethrvmn.gr>2025-09-20 22:27:35 +0000
committeraethrvmn <me@aethrvmn.gr>2025-09-20 22:27:35 +0000
commit9b5f3fad7068298265dbbc8a65077f7917a090a5 (patch)
tree0905b29eb7c03d6bc6e16dd1ebcd1ec9b6b83320 /themes/hugo-book/layouts/_shortcodes
parentsuper simple setup guide (diff)
updated hugo-book theme
Diffstat (limited to 'themes/hugo-book/layouts/_shortcodes')
-rw-r--r--themes/hugo-book/layouts/_shortcodes/badge.html5
-rw-r--r--themes/hugo-book/layouts/_shortcodes/button.html5
-rw-r--r--themes/hugo-book/layouts/_shortcodes/card.html22
-rw-r--r--themes/hugo-book/layouts/_shortcodes/columns.html21
-rw-r--r--themes/hugo-book/layouts/_shortcodes/details.html7
-rw-r--r--themes/hugo-book/layouts/_shortcodes/hint.html3
-rw-r--r--themes/hugo-book/layouts/_shortcodes/html.html1
-rw-r--r--themes/hugo-book/layouts/_shortcodes/i18n.html2
-rw-r--r--themes/hugo-book/layouts/_shortcodes/image.html12
-rw-r--r--themes/hugo-book/layouts/_shortcodes/katex.html19
-rw-r--r--themes/hugo-book/layouts/_shortcodes/mermaid.html12
-rw-r--r--themes/hugo-book/layouts/_shortcodes/section.html13
-rw-r--r--themes/hugo-book/layouts/_shortcodes/steps.html3
-rw-r--r--themes/hugo-book/layouts/_shortcodes/tab.html9
-rw-r--r--themes/hugo-book/layouts/_shortcodes/tabs.html3
15 files changed, 137 insertions, 0 deletions
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") -}}
+<span class="book-badge {{ $style }}">
+ {{- with .Get "title" }}<span class="book-badge-title">{{ . | plainify }}</span>{{ end -}}
+ {{- with .Get "value" }}<span class="book-badge-value">{{ . | plainify }}</span>{{ end -}}
+</span> \ 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}}
+<a {{ with $href }}href="{{ $href }}"{{ end }} {{ with $isRemote }}target="_blank" rel="noopener"{{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
+ {{- .InnerDeindent -}}
+</a>
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" .) -}}
+<a class="book-card{{ with $.Get "class" }} {{ . }}{{ end }}" href="{{ $destination | safeURL }}">
+{{- template "book-card-content" $ -}}
+</a>
+{{- else -}}
+<div class="book-card{{ with .Get "class" }} {{ . }}{{ end }}">
+{{- template "book-card-content" $ -}}
+</div>
+{{- end -}}
+
+{{- define "book-card-content" -}}
+{{- with .Get "image" -}}
+ {{- $destination := partial "docs/links/portable-image" (dict "Page" $.Page "Destination" .) -}}
+ <img src="{{ $destination | safeURL }}" />
+{{- end }}
+ <div class="markdown-inner">
+ {{ with .InnerDeindent }}{{ . }}{{ end }}
+ </div>
+{{- 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." -}}
+<div class="book-columns flex flex-wrap{{ with .Get "class" }} {{ . }}{{ end }}">
+{{ range $index, $content := split .InnerDeindent "<--->" }}
+ {{- $grow := default 1 (index $ratio $index) -}}
+ <div class="flex-even markdown-inner" style="flex-grow: {{ $grow }};">
+ {{ $content | safeHTML }}
+ </div>
+{{ end }}
+</div>
+{{ else }}
+{{- if .Get "ratio" }}<style>{{ range $index, $grow := $ratio }}
+ .book-columns-{{ $.Ordinal }}>ul>li:nth-child({{ $index | add 1 }}){
+ flex-grow: {{ default 1 $grow }};
+ }
+{{ end }}</style>{{ end -}}
+<div class="book-columns book-columns-{{ .Ordinal }} {{ with .Get "class" }}{{ . }}{{ end }}">
+{{ .InnerDeindent | safeHTML }}
+</div>
+{{ 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 @@
+<details {{ if or (.Get "open") (in .Params "open") }}open{{ end }}>
+ {{- $summary := cond .IsNamedParams (.Get "title") (.Get 0) -}}
+ <summary>{{ $summary }}</summary>
+ <div class="markdown-inner">
+ {{ .InnerDeindent | safeHTML }}
+ </div>
+</details>
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 @@
+<blockquote class="book-hint {{ default "default" (.Get 0) }}">
+ {{ .Inner | safeHTML }}
+</blockquote>
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")) -}}
+<label class="book-image" for="book-image-toggle-{{ .Ordinal }}">
+ <input class="hidden toggle" type="checkbox" id="book-image-toggle-{{ .Ordinal }}" />
+ <img src="{{ $destination | safeURL }}"
+ {{- with .Get "alt"}} alt="{{ . }}"{{ end -}}
+ {{- with .Get "title"}} title="{{ . }}"{{ end -}}
+ {{- with .Get "loading"}} loading="{{ . }}"{{ end -}}
+ {{- with .Get "class"}} class="{{ . }}"{{ end -}}
+ />
+</label>
+{{- /* 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") -}}
+<!-- Include katex only first time -->
+<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" />
+<script defer src="{{ "katex/katex.min.js" | relURL }}"></script>
+{{ with resources.Get "katex.json" }}
+ <script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body, {{ .Content | safeJS }});"></script>
+{{ end }}
+{{- .Page.Store.Set "katex" true -}}
+{{- end -}}
+
+{{ if .Inner }}
+<span>
+ {{- if .Get "display" }}
+ \[ {{ .Inner }} \]
+ {{ else }}
+ \( {{ .Inner }} \)
+ {{ end -}}
+</span>
+{{ 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") }}
+<!-- Include mermaid only first time -->
+<script src="{{ "mermaid.min.js" | relURL }}"></script>
+{{ with resources.Get "mermaid.json" }}
+ <script>mermaid.initialize({{ .Content | safeJS }})</script>
+{{ end }}
+{{ .Page.Store.Set "mermaid" true }}
+{{ end }}
+
+<pre class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
+ {{- .Inner | htmlEscape | safeHTML -}}
+</pre>
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" -}}
+<dl>
+{{ range .Page.Pages }}
+ <dt>
+ <a href="{{ .RelPermalink }}">{{ partial "docs/title" . }}</a>
+ </dt>
+ {{ if (in $.Params "summary") -}}
+ <dd class="markdown-inner">
+ {{ default .Summary .Description }}
+ </dd>
+ {{ end -}}
+{{ end }}
+</dl>
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 @@
+<div class="book-steps {{ with .Get "class" }}{{ . }}{{ end }}">
+ {{ .Inner }}
+</div> \ 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 }}
+<input type="radio" class="toggle" name="{{ $group }}" id="{{ $tab }}" {{ if not .Ordinal }}checked="checked"{{ end }} />
+<label for="{{ $tab }}">
+ {{- .Get 0 -}}
+</label>
+<div class="book-tabs-content markdown-inner">
+ {{- .Inner -}}
+</div>
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 @@
+<div class="book-tabs">
+{{ .Inner }}
+</div>
Directive (EU) 2019/790, Article 4(3); all rights regarding Text and Data Mining (TDM) are reserved.