shortcodes: change context parameter to page if called as partial #595

This commit is contained in:
Sören Weber 2023-07-27 16:14:55 +02:00
parent 09ffd597a1
commit 5e71d61c46
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
60 changed files with 214 additions and 135 deletions

View file

@ -27,7 +27,7 @@ While the examples are using shortcodes with named parameter you are free to als
````go ````go
{{ partial "shortcodes/attachments.html" (dict {{ partial "shortcodes/attachments.html" (dict
"context" . "page" .
"sort" "asc" "sort" "asc"
)}} )}}
```` ````

View file

@ -31,30 +31,30 @@ While the examples are using shortcodes with named parameter you are free to als
````go ````go
{{ partial "shortcodes/badge.html" (dict {{ partial "shortcodes/badge.html" (dict
"context" . "page" .
"content" "Important" "content" "Important"
)}} )}}
{{ partial "shortcodes/badge.html" (dict {{ partial "shortcodes/badge.html" (dict
"context" . "page" .
"style" "primary" "style" "primary"
"title" "Version" "title" "Version"
"content" "6.6.6" "content" "6.6.6"
)}} )}}
{{ partial "shortcodes/badge.html" (dict {{ partial "shortcodes/badge.html" (dict
"context" . "page" .
"style" "red" "style" "red"
"icon" "angle-double-up" "icon" "angle-double-up"
"content" "Captain" "content" "Captain"
)}} )}}
{{ partial "shortcodes/badge.html" (dict {{ partial "shortcodes/badge.html" (dict
"context" . "page" .
"style" "info" "style" "info"
"content" "New" "content" "New"
)}} )}}
{{ partial "shortcodes/badge.html" (dict {{ partial "shortcodes/badge.html" (dict
"context" . "page" .
"color" "fuchsia" "color" "fuchsia"
"icon" "fab fa-hackerrank" "icon" "fab fa-hackerrank"
"content" "Awesome" "content" "Awesome"
)}} )}}
```` ````

View file

@ -25,12 +25,12 @@ While the examples are using shortcodes with named parameter you are free to als
````go ````go
{{ partial "shortcodes/button.html" (dict {{ partial "shortcodes/button.html" (dict
"context" . "page" .
"href" "https://gohugo.io/" "href" "https://gohugo.io/"
"content" "Get Hugo" "content" "Get Hugo"
)}} )}}
{{ partial "shortcodes/button.html" (dict {{ partial "shortcodes/button.html" (dict
"context" . "page" .
"href" "https://gohugo.io/" "href" "https://gohugo.io/"
"style" "warning" "style" "warning"
"icon" "dragon" "icon" "dragon"

View file

@ -24,7 +24,7 @@ While the examples are using shortcodes with named parameter you are free to als
````go ````go
{{ partial "shortcodes/children.html" (dict {{ partial "shortcodes/children.html" (dict
"context" . "page" .
"sort" "weight" "sort" "weight"
)}} )}}
```` ````

View file

@ -46,7 +46,7 @@ While the examples are using shortcodes with named parameter you are free to use
````go ````go
{{ partial "shortcodes/expand.html" (dict {{ partial "shortcodes/expand.html" (dict
"context" . "page" .
"title" "Expand me..." "title" "Expand me..."
"content" "Thank you!" "content" "Thank you!"
)}} )}}

View file

@ -52,7 +52,7 @@ print("Hello World!")
````go ````go
{{ partial "shortcodes/highlight.html" (dict {{ partial "shortcodes/highlight.html" (dict
"context" . "page" .
"content" "print(\"Hello World!\")" "content" "print(\"Hello World!\")"
"lineNos" "true" "lineNos" "true"
"type" "py" "type" "py"
@ -66,7 +66,7 @@ print("Hello World!")
````go ````go
{{ partial "shortcodes/highlight.html" (dict {{ partial "shortcodes/highlight.html" (dict
"context" . "page" .
"content" "print(\"Hello World!\")" "content" "print(\"Hello World!\")"
"options" "lineNos=true,wrap=true" "options" "lineNos=true,wrap=true"
"type" "py" "type" "py"

View file

@ -37,15 +37,15 @@ While the examples are using shortcodes with positional parameter you are free t
````go ````go
{{ partial "shortcodes/icon.html" (dict {{ partial "shortcodes/icon.html" (dict
"context" . "page" .
"icon" "exclamation-triangle" "icon" "exclamation-triangle"
)}} )}}
{{ partial "shortcodes/icon.html" (dict {{ partial "shortcodes/icon.html" (dict
"context" . "page" .
"icon" "angle-double-up" "icon" "angle-double-up"
)}} )}}
{{ partial "shortcodes/icon.html" (dict {{ partial "shortcodes/icon.html" (dict
"context" . "page" .
"icon" "skull-crossbones" "icon" "skull-crossbones"
)}} )}}
```` ````

View file

@ -28,7 +28,7 @@ While the examples are using shortcodes with named parameter you are free to use
````go ````go
{{ partial "shortcodes/include .html" (dict {{ partial "shortcodes/include .html" (dict
"context" . "page" .
"file" "shortcodes/INCLUDE_ME.md" "file" "shortcodes/INCLUDE_ME.md"
)}} )}}
```` ````

View file

@ -46,7 +46,7 @@ $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \
````go ````go
{{ partial "shortcodes/math.html" (dict {{ partial "shortcodes/math.html" (dict
"context" . "page" .
"content" "$$left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$" "content" "$$left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$"
"align" "center" "align" "center"
)}} )}}

View file

@ -56,7 +56,7 @@ graph LR;
````go ````go
{{ partial "shortcodes/mermaid.html" (dict {{ partial "shortcodes/mermaid.html" (dict
"context" . "page" .
"content" "graph LR;\nIf --> Then\nThen --> Else" "content" "graph LR;\nIf --> Then\nThen --> Else"
"align" "center" "align" "center"
"zoom" "true" "zoom" "true"

View file

@ -36,7 +36,7 @@ It is all about the boxes.
````go ````go
{{ partial "shortcodes/notice.html" (dict {{ partial "shortcodes/notice.html" (dict
"context" . "page" .
"style" "primary" "style" "primary"
"title" "There may be pirates" "title" "There may be pirates"
"icon" "skull-crossbones" "icon" "skull-crossbones"

View file

@ -25,8 +25,8 @@ While the examples are using shortcodes with named parameter you are free to als
````go ````go
{{ partial "shortcodes/openapi.html" (dict {{ partial "shortcodes/openapi.html" (dict
"context" . "page" .
"src" "https://petstore3.openapi.io/api/v3/openapi.json" "src" "https://petstore3.openapi.io/api/v3/openapi.json"
)}} )}}
```` ````

View file

@ -29,7 +29,7 @@ While the examples are using shortcodes with named parameter you are free to use
````go ````go
{{ partial "shortcodes/siteparam.html" (dict {{ partial "shortcodes/siteparam.html" (dict
"context" . "page" .
"name" "editURL" "name" "editURL"
)}} )}}
```` ````

View file

@ -37,7 +37,7 @@ printf("Hello World!");
````go ````go
{{ partial "shortcodes/tab.html" (dict {{ partial "shortcodes/tab.html" (dict
"context" . "page" .
"title" "c" "title" "c"
"content" ("```c\nprintf(\"Hello World!\")\n```" | .RenderString) "content" ("```c\nprintf(\"Hello World!\")\n```" | .RenderString)
)}} )}}

View file

@ -67,7 +67,7 @@ printf"Hello World!");
````go ````go
{{ partial "shortcodes/tabs.html" (dict {{ partial "shortcodes/tabs.html" (dict
"context" . "page" .
"title" "hello." "title" "hello."
"content" (slice "content" (slice
(dict (dict

View file

@ -1,21 +1,26 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'piratify' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $content := .content }} {{- $content := .content }}
{{- $pagefield := cond (ne $content nil) nil (.pagefield | default "Content") }} {{- $pagefield := cond (ne $content nil) nil (.pagefield | default "Content") }}
{{- $writenotice := cond (ne .writenotice nil) .writenotice false }} {{- $writenotice := cond (ne .writenotice nil) .writenotice false }}
{{- $langtrg := "pir" }} {{- $langtrg := "pir" }}
{{- $langsrc := cond (eq $context.Lang $langtrg) (.langsrc | default "en") $context.Lang }} {{- $langsrc := cond (eq $page.Lang $langtrg) (.langsrc | default "en") $page.Lang }}
{{- $baseURL := urls.Parse site.BaseURL }} {{- $baseURL := urls.Parse site.BaseURL }}
{{- $baseURLpath := $baseURL.Path | default "/" }} {{- $baseURLpath := $baseURL.Path | default "/" }}
{{- $l := $context.RelPermalink }} {{- $l := $page.RelPermalink }}
{{- $c := "" }} {{- $c := "" }}
{{- $srcPage := "" }}
{{- if ne $content nil }} {{- if ne $content nil }}
{{- $c = $content }} {{- $c = $content }}
{{- else if eq $pagefield "Content" }} {{- else if eq $pagefield "Content" }}
{{- $c = $context.Content }} {{- $c = $page.Content }}
{{- else if eq $pagefield "TableOfContents" }} {{- else if eq $pagefield "TableOfContents" }}
{{- $c = $context.TableOfContents }} {{- $c = $page.TableOfContents }}
{{- end }} {{- end }}
{{- range $context.AllTranslations }} {{- range $page.AllTranslations }}
{{- if eq .Language.Lang $langsrc }} {{- if eq .Language.Lang $langsrc }}
{{- $l = .RelPermalink }} {{- $l = .RelPermalink }}
{{- if ne $content nil }} {{- if ne $content nil }}
@ -29,10 +34,10 @@
{{- break }} {{- break }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if eq $context.Lang $langtrg }} {{- if eq $page.Lang $langtrg }}
{{- if $writenotice }} {{- if $writenotice }}
{{- partial "shortcodes/notice.html" (dict {{- partial "shortcodes/notice.html" (dict
"context" $context "page" $page
"content" "<p>Fello' pirrrates, grog made us dizzy! Be awarrre <b>some stuff may look weird</b> in this trrranslat'n. Like <b>Merrrmaids</b>, do'n <b>math or chemistrrry</b> and stuff.</p>\n" "content" "<p>Fello' pirrrates, grog made us dizzy! Be awarrre <b>some stuff may look weird</b> in this trrranslat'n. Like <b>Merrrmaids</b>, do'n <b>math or chemistrrry</b> and stuff.</p>\n"
"icon" "skull-crossbones" "icon" "skull-crossbones"
"style" "warning" "style" "warning"
@ -128,9 +133,9 @@
{{- end }} {{- end }}
{{- $c = replaceRE (printf "(src|href)=\"([^\"]*?)/%s/([^\"]*?.files/[^\"]*?\")" $langtrg) "${1}=\"${2}/${3}" $c }} {{- $c = replaceRE (printf "(src|href)=\"([^\"]*?)/%s/([^\"]*?.files/[^\"]*?\")" $langtrg) "${1}=\"${2}/${3}" $c }}
{{- if $srcPage }} {{- if $srcPage }}
{{- $context.Store.Set "hasMathJax" (or ($context.Store.Get "hasMathJax") ($srcPage.Store.Get "hasMathJax")) }} {{- $page.Store.Set "hasMathJax" (or ($page.Store.Get "hasMathJax") ($srcPage.Store.Get "hasMathJax")) }}
{{- $context.Store.Set "hasMermaid" (or ($context.Store.Get "hasMermaid") ($srcPage.Store.Get "hasMermaid")) }} {{- $page.Store.Set "hasMermaid" (or ($page.Store.Get "hasMermaid") ($srcPage.Store.Get "hasMermaid")) }}
{{- $context.Store.Set "hasOpenapi" (or ($context.Store.Get "hasOpenapi") ($srcPage.Store.Get "hasOpenapi")) }} {{- $page.Store.Set "hasOpenapi" (or ($page.Store.Get "hasOpenapi") ($srcPage.Store.Get "hasOpenapi")) }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{ $c | safeHTML }} {{ $c | safeHTML }}

View file

@ -15,7 +15,7 @@
</nav> </nav>
{{- else }} {{- else }}
{{- partial "shortcodes/piratify.html" (dict {{- partial "shortcodes/piratify.html" (dict
"context" . "page" .
"pagefield" "TableOfContents" "pagefield" "TableOfContents"
) }} ) }}
{{- end }} {{- end }}

View file

@ -1,5 +1,5 @@
{{- partial "shortcodes/piratify.html" (dict {{- partial "shortcodes/piratify.html" (dict
"context" .Page "page" .Page
"pagefield" "Content" "pagefield" "Content"
"writenotice" (.Get "writenotice" | default (.Get 0)) "writenotice" (.Get "writenotice" | default (.Get 0))
) }} ) }}

View file

@ -66,7 +66,7 @@
<main id="body-inner" class="chapter" tabindex="-1"> <main id="body-inner" class="chapter" tabindex="-1">
<div class="flex-block-wrapper"> <div class="flex-block-wrapper">
<article> <article>
<h1 id="404"><span>4</span>{{ partial "shortcodes/icon.html" (dict "context" . "icon" "far fa-frown" )}}<span>4</span></h1> <h1 id="404"><span>4</span>{{ partial "shortcodes/icon.html" (dict "page" . "icon" "far fa-frown" )}}<span>4</span></h1>
<h2 id="{{ T "title-404" | anchorize }}">{{ T "title-404" }}</h2> <h2 id="{{ T "title-404" | anchorize }}">{{ T "title-404" }}</h2>
<p></p> <p></p>
<p>{{ T "message-404" }}</p> <p>{{ T "message-404" }}</p>

View file

@ -1,5 +1,5 @@
{{- partial "shortcodes/math.html" (dict {{- partial "shortcodes/math.html" (dict
"context" .Page "page" .Page
"content" .Inner "content" .Inner
"align" (index .Attributes "align") "align" (index .Attributes "align")
) }} ) }}

View file

@ -1,5 +1,5 @@
{{- partial "shortcodes/mermaid.html" (dict {{- partial "shortcodes/mermaid.html" (dict
"context" .Page "page" .Page
"content" .Inner "content" .Inner
"align" (index .Attributes "align") "align" (index .Attributes "align")
) }} ) }}

View file

@ -1,5 +1,5 @@
{{- partial "shortcodes/highlight.html" (dict {{- partial "shortcodes/highlight.html" (dict
"context" .Page "page" .Page
"attributes" .Attributes "attributes" .Attributes
"content" .Inner "content" .Inner
"options" .Options "options" .Options

View file

@ -6,7 +6,7 @@
{{- $id = "" }} {{- $id = "" }}
{{- end }} {{- end }}
{{- partial "shortcodes/image.html" (dict {{- partial "shortcodes/image.html" (dict
"context" .Page "page" .Page
"url" .Destination "url" .Destination
"title" .Title "title" .Title
"alt" .Text "alt" .Text

View file

@ -1,5 +1,5 @@
{{- partial "shortcodes/link.html" (dict {{- partial "shortcodes/link.html" (dict
"context" .Page "page" .Page
"url" .Destination "url" .Destination
"title" .Title "title" .Title
"content" .Text "content" .Text

View file

@ -10,7 +10,7 @@
<label class="a11y-only" for="search-by-detail">{{ T "Search" }}</label> <label class="a11y-only" for="search-by-detail">{{ T "Search" }}</label>
<input data-search-input id="search-by-detail" class="search-by" name="search-by" type="search" placeholder="{{ T "Search-placeholder" }}"> <input data-search-input id="search-by-detail" class="search-by" name="search-by" type="search" placeholder="{{ T "Search-placeholder" }}">
{{- partial "shortcodes/button.html" (dict {{- partial "shortcodes/button.html" (dict
"context" $page "page" $page
"type" "submit" "type" "submit"
"style" "secondary" "style" "secondary"
"icon" "search" "icon" "search"

View file

@ -1,5 +1,5 @@
{{- $context := . }} {{- $page := . }}
{{- if (ne $context.Site.Params.disableRandomIds true) }} {{- if (ne $page.Site.Params.disableRandomIds true) }}
{{- $random := "" }} {{- $random := "" }}
{{- $set := split "012345abcdefghijklmnopqrstuvwxyz" "" }} {{- $set := split "012345abcdefghijklmnopqrstuvwxyz" "" }}
{{- range (seq 16) }} {{- range (seq 16) }}

View file

@ -1,7 +1,11 @@
{{- $version := split hugo.Version "." }} {{- $version := split hugo.Version "." }}
{{- $major := int (index $version 0) }} {{- $major := int (index $version 0) }}
{{- $minor := int (index $version 1) }} {{- $minor := int (index $version 1) }}
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'attachments' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $color := .color | default "" }} {{- $color := .color | default "" }}
{{- $content := .content }} {{- $content := .content }}
{{- $style := .style | default "default" }} {{- $style := .style | default "default" }}
@ -24,19 +28,19 @@
{{- end }} {{- end }}
{{- $sort := .sort | default "asc" }} {{- $sort := .sort | default "asc" }}
{{- $pattern := .pattern | default "" }} {{- $pattern := .pattern | default "" }}
{{- $defaultUrlPrefix := strings.TrimRight "/" $context.RelPermalink }} {{- $defaultUrlPrefix := strings.TrimRight "/" $page.RelPermalink }}
{{- if .IsTranslated -}} {{- if .IsTranslated -}}
{{- $defaultLanguage := (index $context.Site.Home.AllTranslations 0).Lang }} {{- $defaultLanguage := (index $page.Site.Home.AllTranslations 0).Lang }}
{{- $defaultLanguagePage := index (where $context.AllTranslations "Language.Lang" $defaultLanguage) 0 }} {{- $defaultLanguagePage := index (where $page.AllTranslations "Language.Lang" $defaultLanguage) 0 }}
{{- $defaultUrlPrefix = strings.TrimRight "/" $defaultLanguagePage.RelPermalink }} {{- $defaultUrlPrefix = strings.TrimRight "/" $defaultLanguagePage.RelPermalink }}
{{- end }} {{- end }}
{{- $urlPrefix := strings.TrimRight "/" $context.RelPermalink }} {{- $urlPrefix := strings.TrimRight "/" $page.RelPermalink }}
{{- with $context }} {{- with $page }}
{{- if ne .BundleType "leaf" }} {{- if ne .BundleType "leaf" }}
{{- if or (and (eq $major 0) (ge $minor 112)) (gt $major 0) }} {{- if or (and (eq $major 0) (ge $minor 112)) (gt $major 0) }}
{{- warnf "%q: UNSUPPORTED usage of 'attachments' shortcode found while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $context.File.Path }} {{- warnf "%q: UNSUPPORTED usage of 'attachments' shortcode found while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $page.File.Path }}
{{- else }} {{- else }}
{{- warnf "%q: DEPRECATED usage of 'attachments' shortcode found which will not be compatible while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $context.File.Path }} {{- warnf "%q: DEPRECATED usage of 'attachments' shortcode found which will not be compatible while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $page.File.Path }}
{{- end }} {{- end }}
{{- end }} {{- end }}
<div class="box attachments cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}> <div class="box attachments cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}>

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'badge' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $color := .color | default "" }} {{- $color := .color | default "" }}
{{- $content := .content }} {{- $content := .content }}
{{- $style := .style | default "default" }} {{- $style := .style | default "default" }}
@ -15,6 +19,6 @@
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
{{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- $icon = printf "fa-fw fas fa-%s" $icon }}
{{- end }} {{- end }}
{{- with $context -}} {{- with $page -}}
<span class="badge cstyle {{ $style }}{{ if or $icon $title }} badge-with-title{{ end }}">{{ if or $icon $title }}<span class="badge-title">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ if $title }}{{ $title | .RenderString }}{{ end }}</span>{{ end }}<span class="badge-content"{{ if $color }} style="background-color: {{ $color }};"{{ end }}>{{ $content }}</span></span> <span class="badge cstyle {{ $style }}{{ if or $icon $title }} badge-with-title{{ end }}">{{ if or $icon $title }}<span class="badge-title">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ if $title }}{{ $title | .RenderString }}{{ end }}</span>{{ end }}<span class="badge-content"{{ if $color }} style="background-color: {{ $color }};"{{ end }}>{{ $content }}</span></span>
{{- end }} {{- end }}

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'button' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $color := .color | default "" }} {{- $color := .color | default "" }}
{{- $content := .content }} {{- $content := .content }}
{{- $href := (trim .href " ") | default "" }} {{- $href := (trim .href " ") | default "" }}
@ -17,8 +21,8 @@
{{- end }} {{- end }}
{{- else if and (eq (len $target) 0) (or (strings.HasPrefix $href "http://") (strings.HasPrefix $href "https://") ) }} {{- else if and (eq (len $target) 0) (or (strings.HasPrefix $href "http://") (strings.HasPrefix $href "https://") ) }}
{{- $target = "_blank" }} {{- $target = "_blank" }}
{{- if isset $context.Site.Params "externallinktarget" }} {{- if isset $page.Site.Params "externallinktarget" }}
{{- $target = $context.Site.Params.externalLinkTarget }} {{- $target = $page.Site.Params.externalLinkTarget }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- $title := .title | default ($content) | default ($style | T) }} {{- $title := .title | default ($content) | default ($style | T) }}
@ -35,7 +39,7 @@
{{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- $icon = printf "fa-fw fas fa-%s" $icon }}
{{- end }} {{- end }}
{{- $iconposition := .iconposition | default "left" }} {{- $iconposition := .iconposition | default "left" }}
{{- with $context }} {{- with $page }}
<span class="btn cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}> <span class="btn cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}>
{{- if $isButton }} {{- if $isButton }}
<button{{ if $href }} onclick="{{ $href | safeJS }}"{{ end }}{{ if gt (len $type) 0 }} type="{{ $type }}"{{ end }}> <button{{ if $href }} onclick="{{ $href | safeJS }}"{{ end }}{{ if gt (len $type) 0 }} type="{{ $type }}"{{ end }}>

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'children' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $showhidden := .showhidden | default false }} {{- $showhidden := .showhidden | default false }}
{{- if eq (printf "%T" $showhidden) "string" }} {{- if eq (printf "%T" $showhidden) "string" }}
{{- $showhidden = (eq $showhidden "true") }} {{- $showhidden = (eq $showhidden "true") }}
@ -15,30 +19,30 @@
{{- $containerstyle = "div" }} {{- $containerstyle = "div" }}
{{- end }} {{- end }}
{{- with $context }} {{- with $page }}
{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }} {{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }}
{{- $pages := .Pages }} {{- $pages := .Pages }}
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }} {{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
{{- $currentOrdersectionsby := $sortTerm | default (.Params.ordersectionsby | default $defaultOrdersectionsby) }} {{- $currentOrdersectionsby := $sortTerm | default (.Params.ordersectionsby | default $defaultOrdersectionsby) }}
{{- if eq $currentOrdersectionsby "weight" }} {{- if eq $currentOrdersectionsby "weight" }}
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }} {{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }}
{{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }} {{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }}
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }} {{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }}
{{- else if eq $currentOrdersectionsby "publishdate" }} {{- else if eq $currentOrdersectionsby "publishdate" }}
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }} {{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }}
{{- else if eq $currentOrdersectionsby "date" }} {{- else if eq $currentOrdersectionsby "date" }}
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }} {{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }}
{{- else if eq $currentOrdersectionsby "length" }} {{- else if eq $currentOrdersectionsby "length" }}
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }} {{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }}
{{- else }} {{- else }}
{{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }} {{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }}
{{- end }} {{- end }}
{{ (printf "</%s>" $containerstyle)|safeHTML }} {{ (printf "</%s>" $containerstyle)|safeHTML }}
{{- end }} {{- end }}
{{- define "childs" }} {{- define "childs" }}
{{ $context := .context }} {{ $page := .page }}
{{- range .menu }} {{- range .menu }}
{{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }} {{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
{{- if not $hidden }} {{- if not $hidden }}
@ -88,17 +92,17 @@
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }} {{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
{{- $currentOrdersectionsby := $.sortTerm | default (.Params.ordersectionsby | default $defaultOrdersectionsby) }} {{- $currentOrdersectionsby := $.sortTerm | default (.Params.ordersectionsby | default $defaultOrdersectionsby) }}
{{- if eq $currentOrdersectionsby "weight" }} {{- if eq $currentOrdersectionsby "weight" }}
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }} {{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }}
{{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }} {{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }}
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }} {{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }}
{{- else if eq $.currentOrdersectionsby "publishdate" }} {{- else if eq $.currentOrdersectionsby "publishdate" }}
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }} {{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }}
{{- else if eq $.currentOrdersectionsby "date" }} {{- else if eq $.currentOrdersectionsby "date" }}
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }} {{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }}
{{- else if eq $.currentOrdersectionsby "length" }} {{- else if eq $.currentOrdersectionsby "length" }}
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }} {{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }}
{{- else }} {{- else }}
{{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }} {{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }}
{{- end }} {{- end }}
{{- if eq $.style "li" }} {{- if eq $.style "li" }}

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'expand' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $content := .content }} {{- $content := .content }}
{{- $title := .title | default (T "Expand-title") }} {{- $title := .title | default (T "Expand-title") }}
{{- $title = trim $title " " }} {{- $title = trim $title " " }}
@ -6,8 +10,8 @@
{{- if eq (printf "%T" $expanded) "string" }} {{- if eq (printf "%T" $expanded) "string" }}
{{- $expanded = (eq $expanded "true") }} {{- $expanded = (eq $expanded "true") }}
{{- end }} {{- end }}
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }} {{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }}
{{- with $context }} {{- with $page }}
<div class="expand"> <div class="expand">
<input type="checkbox" id="expand-{{ $id }}" aria-controls="expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}> <input type="checkbox" id="expand-{{ $id }}" aria-controls="expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
<label class="expand-label" for="expand-{{ $id }}" > <label class="expand-label" for="expand-{{ $id }}" >

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'highlight' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $attributes := dict }} {{- $attributes := dict }}
{{- $otherAttributes := dict }} {{- $otherAttributes := dict }}
{{- $content := "" }} {{- $content := "" }}
@ -45,11 +49,11 @@
{{- end }} {{- end }}
{{- $params = delimit $params ", " }} {{- $params = delimit $params ", " }}
{{- $wrap := true }} {{- $wrap := true }}
{{- if isset $context.Site.Params "highlightwrap" }} {{- if isset $page.Site.Params "highlightwrap" }}
{{- $wrap = $context.Site.Params.highlightWrap }} {{- $wrap = $page.Site.Params.highlightWrap }}
{{- end }} {{- end }}
{{- if isset $context.Params "highlightwrap" }} {{- if isset $page.Params "highlightwrap" }}
{{- $wrap = $context.Params.highlightWrap }} {{- $wrap = $page.Params.highlightWrap }}
{{- end }} {{- end }}
{{- range $k, $v := $attributes }} {{- range $k, $v := $attributes }}
{{- if eq $k "wrap" }} {{- if eq $k "wrap" }}

View file

@ -1,10 +1,14 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'icon' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $icon := .icon | default "" }} {{- $icon := .icon | default "" }}
{{- $icon = trim $icon " " }} {{- $icon = trim $icon " " }}
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
{{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- $icon = printf "fa-fw fas fa-%s" $icon }}
{{- end }} {{- end }}
{{- with $context }} {{- with $page }}
{{- if $icon -}} {{- if $icon -}}
<i class="{{ $icon }}"></i> <i class="{{ $icon }}"></i>
{{- end }} {{- end }}

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'image' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $url := .url }} {{- $url := .url }}
{{- $title := .title }} {{- $title := .title }}
{{- $alt := .alt }} {{- $alt := .alt }}
@ -8,7 +12,7 @@
{{- $width := "auto" }} {{- $width := "auto" }}
{{- $dest_url := urls.Parse $url }} {{- $dest_url := urls.Parse $url }}
{{- $dest_path := $dest_url.Path }} {{- $dest_path := $dest_url.Path }}
{{- $image := $context.Resources.GetMatch $dest_path }} {{- $image := $page.Resources.GetMatch $dest_path }}
{{- if not $image }} {{- if not $image }}
{{- $image = .Resources.GetMatch $dest_path }} {{- $image = .Resources.GetMatch $dest_path }}
{{- end }} {{- end }}
@ -26,7 +30,7 @@
{{- $classes = $classes | append (split ($dest_url.Query.Get "classes") ",") }} {{- $classes = $classes | append (split ($dest_url.Query.Get "classes") ",") }}
{{- end }} {{- end }}
{{- if $dest_url.Query.Has "featherlight" }} {{- if $dest_url.Query.Has "featherlight" }}
{{- warnf "%q: DEPRECATED usage of 'featherlight' image CSS class found, use 'lightbox' instead; see http://localhost:1313/basics/migration/#5110-2023-02-07" $context.File.Path }} {{- warnf "%q: DEPRECATED usage of 'featherlight' image CSS class found, use 'lightbox' instead; see http://localhost:1313/basics/migration/#5110-2023-02-07" $page.File.Path }}
{{- end }} {{- end }}
{{- $lightbox = and (ne ($dest_url.Query.Get "lightbox") "false") (ne ($dest_url.Query.Get "featherlight") "false") }} {{- $lightbox = and (ne ($dest_url.Query.Get "lightbox") "false") (ne ($dest_url.Query.Get "featherlight") "false") }}
{{- with $dest_url.Query.Get "height" }} {{- with $dest_url.Query.Get "height" }}
@ -36,7 +40,7 @@
{{ $width = . }} {{ $width = . }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }} {{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }}
{{- if $lightbox }} {{- if $lightbox }}
<a href="#image-{{ $id }}" class="lightbox-link"> <a href="#image-{{ $id }}" class="lightbox-link">
{{- end }} {{- end }}

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'include' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $file := .file }} {{- $file := .file }}
{{- $hideFirstHeading := .hidefirstheading | default false }} {{- $hideFirstHeading := .hidefirstheading | default false }}
{{- if eq (printf "%T" $hideFirstHeading) "string" }} {{- if eq (printf "%T" $hideFirstHeading) "string" }}
@ -6,7 +10,7 @@
{{- end }} {{- end }}
{{- if and (gt (len (trim $file " ")) 0) (fileExists $file) }} {{- if and (gt (len (trim $file " ")) 0) (fileExists $file) }}
{{- if $hideFirstHeading }}<div class="include hide-first-heading">{{ end }} {{- if $hideFirstHeading }}<div class="include hide-first-heading">{{ end }}
{{- with $context }} {{- with $page }}
{{ $file | readFile | safeHTML }} {{ $file | readFile | safeHTML }}

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'link' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $url := .url }} {{- $url := .url }}
{{- $title := .title | default "" }} {{- $title := .title | default "" }}
{{- $title = trim $title " " }} {{- $title = trim $title " " }}
@ -6,8 +10,8 @@
{{- $target := .target | default "" }} {{- $target := .target | default "" }}
{{- if and (eq (len $target) 0) (or (strings.HasPrefix $url "http://") (strings.HasPrefix $url "https://") ) }} {{- if and (eq (len $target) 0) (or (strings.HasPrefix $url "http://") (strings.HasPrefix $url "https://") ) }}
{{- $target = "_blank" }} {{- $target = "_blank" }}
{{- if isset $context.Site.Params "externallinktarget" }} {{- if isset $page.Site.Params "externallinktarget" }}
{{- $target = $context.Site.Params.externalLinkTarget }} {{- $target = $page.Site.Params.externalLinkTarget }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
<a href="{{ $url | safeURL }}"{{ if $title }} title="{{ $title }}"{{ end }}{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}>{{ $content | safeHTML }}</a> <a href="{{ $url | safeURL }}"{{ if $title }} title="{{ $title }}"{{ end }}{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}>{{ $content | safeHTML }}</a>

View file

@ -1,7 +1,11 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'math' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $content := .content }} {{- $content := .content }}
{{- $align := .align | default "center" }} {{- $align := .align | default "center" }}
{{- with $context }} {{- with $page }}
<span class="math align-{{ $align }}"> <span class="math align-{{ $align }}">
{{- $content | safeHTML -}} {{- $content | safeHTML -}}
</span> </span>

View file

@ -1,8 +1,12 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'mermaid' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $content := .content }} {{- $content := .content }}
{{- $align := .align | default "center" }} {{- $align := .align | default "center" }}
{{- $zoom := $context.Site.Params.mermaidZoom | default false }} {{- $zoom := $page.Site.Params.mermaidZoom | default false }}
{{- with $context.Params.mermaidZoom }} {{- with $page.Params.mermaidZoom }}
{{- $zoom = . }} {{- $zoom = . }}
{{- if eq (printf "%T" .) "string" }} {{- if eq (printf "%T" .) "string" }}
{{- $zoom = (eq . "true") }} {{- $zoom = (eq . "true") }}
@ -14,7 +18,7 @@
{{- $zoom = (eq . "true") }} {{- $zoom = (eq . "true") }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $context }} {{- with $page }}
<div class="mermaid align-{{ $align }}{{ if $zoom }} zoom{{ end }}"> <div class="mermaid align-{{ $align }}{{ if $zoom }} zoom{{ end }}">
{{- replaceRE "&#39;" "'" ( replaceRE "&#34;" "\"" ( $content | safeHTML ) ) -}} {{- replaceRE "&#39;" "'" ( replaceRE "&#34;" "\"" ( $content | safeHTML ) ) -}}
</div> </div>

View file

@ -1,4 +1,8 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'notice' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $color := .color | default "" }} {{- $color := .color | default "" }}
{{- $content := .content }} {{- $content := .content }}
{{- $style := .style | default "default" }} {{- $style := .style | default "default" }}
@ -15,7 +19,7 @@
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
{{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- $icon = printf "fa-fw fas fa-%s" $icon }}
{{- end }} {{- end }}
{{- with $context }} {{- with $page }}
<div class="box notices cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}> <div class="box notices cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}>
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | .RenderString }}</div> <div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | .RenderString }}</div>
<div class="box-content"> <div class="box-content">

View file

@ -1,7 +1,11 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'openapi' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $src := .src }} {{- $src := .src }}
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }} {{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }}
{{- with $context }} {{- with $page }}
{{- with .Resources.Match $src }} {{- with .Resources.Match $src }}
{{- range . }} {{- range . }}
{{- $src = .RelPermalink }} {{- $src = .RelPermalink }}

View file

@ -1,6 +1,10 @@
{{- $context := .context }} {{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'siteparam' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $paramNames := split .name "." }} {{- $paramNames := split .name "." }}
{{- with $context }} {{- with $page }}
{{- $params := .Site.Params }} {{- $params := .Site.Params }}
{{- range $paramName := $paramNames }} {{- range $paramName := $paramNames }}
{{- with $params }} {{- with $params }}

View file

@ -1,6 +1,11 @@
{{ warnf "%q: DEPRECATED shortcode `swagger`found, use `openapi` instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5130-2023-05-17" .context.File.Path }} {{ warnf "%q: DEPRECATED shortcode `swagger`found, use `openapi` instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5130-2023-05-17" .context.File.Path }}
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'swagger' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- partial "shortcodes/openapi.html" (dict {{- partial "shortcodes/openapi.html" (dict
"context" .context "page" $page
"src" .src "src" .src
"id" .id "id" .id
) }} ) }}

View file

@ -1,3 +1,8 @@
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'tab' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $tabs := (slice | append (dict {{- $tabs := (slice | append (dict
"color" .color "color" .color
"content" .content "content" .content
@ -7,7 +12,7 @@
"title" .title "title" .title
)) }} )) }}
{{- partial "shortcodes/tabs.html" (dict {{- partial "shortcodes/tabs.html" (dict
"context" .context "page" $page
"color" "" "color" ""
"content" $tabs "content" $tabs
"groupid" "" "groupid" ""

View file

@ -1,5 +1,9 @@
{{- $context := .context }} {{- $page := .page }}
{{- $groupid := .groupid | default (partial "make-random-md5.hugo" $context) }} {{- if and (not $page) .context }}
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'tabs' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180-2023-07-27" $page.File.Path }}
{{- end }}
{{- $groupid := .groupid | default (partial "make-random-md5.hugo" $page) }}
{{- $color := .color }} {{- $color := .color }}
{{- $style := .style }} {{- $style := .style }}
{{- $title := .title }} {{- $title := .title }}
@ -7,7 +11,7 @@
{{- $tabs := slice }} {{- $tabs := slice }}
{{- range $tab := (.content | default slice) }} {{- range $tab := (.content | default slice) }}
{{- if and (not $tab.title) $tab.name }} {{- if and (not $tab.title) $tab.name }}
{{- warnf "%q: DEPRECATED parameter 'name' for shortcode 'tab' found, use 'title' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5160-2023-06-08" $context.File.Path }} {{- warnf "%q: DEPRECATED parameter 'name' for shortcode 'tab' found, use 'title' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5160-2023-06-08" $page.File.Path }}
{{- $tab = merge $tab (dict "title" .name) }} {{- $tab = merge $tab (dict "title" .name) }}
{{- end }} {{- end }}
{{- with $tab }} {{- with $tab }}
@ -30,7 +34,7 @@
"color" $color "color" $color
"content" .content "content" .content
"icon" $icon "icon" $icon
"itemid" (printf "%s%s" ($title | $context.RenderString | plainify) ($icon | plainify)) "itemid" (printf "%s%s" ($title | $page.RenderString | plainify) ($icon | plainify))
"style" $style "style" $style
"title" $title "title" $title
) }} ) }}
@ -51,10 +55,10 @@
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
{{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- $icon = printf "fa-fw fas fa-%s" $icon }}
{{- end }} {{- end }}
{{- with $context }} {{- with $page }}
<div class="tab-panel" data-tab-group="{{ $groupid }}"> <div class="tab-panel" data-tab-group="{{ $groupid }}">
<div class="tab-nav"> <div class="tab-nav">
<div class="tab-nav-title">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | $context.RenderString }}{{ if (not $title) }}&#8203;{{ end }}</div> <div class="tab-nav-title">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | $page.RenderString }}{{ if (not $title) }}&#8203;{{ end }}</div>
{{- range $idx, $tab := $tabs }} {{- range $idx, $tab := $tabs }}
<button <button
data-tab-item="{{ .itemid }}" data-tab-item="{{ .itemid }}"
@ -62,8 +66,8 @@
onclick="switchTab('{{ $groupid }}','{{ .itemid }}')" onclick="switchTab('{{ $groupid }}','{{ .itemid }}')"
> >
<div> <div>
<div class="tab-nav-hidden">{{ if .icon }}<i class="{{ .icon }}"></i>{{ end }}{{ if and .icon .title }} {{ end }}{{ .title | $context.RenderString }}{{ if (not .title) }}&#8203;{{ end }}</div> <div class="tab-nav-hidden">{{ if .icon }}<i class="{{ .icon }}"></i>{{ end }}{{ if and .icon .title }} {{ end }}{{ .title | $page.RenderString }}{{ if (not .title) }}&#8203;{{ end }}</div>
<div class="tab-nav-text">{{ if .icon }}<i class="{{ .icon }}"></i>{{ end }}{{ if and .icon .title }} {{ end }}{{ .title | $context.RenderString }}{{ if (not .title) }}&#8203;{{ end }}</div> <div class="tab-nav-text">{{ if .icon }}<i class="{{ .icon }}"></i>{{ end }}{{ if and .icon .title }} {{ end }}{{ .title | $page.RenderString }}{{ if (not .title) }}&#8203;{{ end }}</div>
</div> </div>
</button> </button>
{{- end }} {{- end }}

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- partial "shortcodes/attachments.html" (dict {{- partial "shortcodes/attachments.html" (dict
"context" .Page "page" .Page
"color" (.Get "color") "color" (.Get "color")
"content" .Inner "content" .Inner
"icon" (.Get "icon") "icon" (.Get "icon")

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- partial "shortcodes/badge.html" (dict {{- partial "shortcodes/badge.html" (dict
"context" .Page "page" .Page
"color" (.Get "color") "color" (.Get "color")
"content" .Inner "content" .Inner
"icon" (.Get "icon") "icon" (.Get "icon")

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- partial "shortcodes/button.html" (dict {{- partial "shortcodes/button.html" (dict
"context" .Page "page" .Page
"color" (.Get "color") "color" (.Get "color")
"content" .Inner "content" .Inner
"href" (.Get "href") "href" (.Get "href")

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- partial "shortcodes/children.html" (dict {{- partial "shortcodes/children.html" (dict
"context" .Page "page" .Page
"containerstyle" (.Get "containerstyle") "containerstyle" (.Get "containerstyle")
"description" (.Get "description") "description" (.Get "description")
"depth" (.Get "depth") "depth" (.Get "depth")

View file

@ -7,7 +7,7 @@
{{- $id = "" }} {{- $id = "" }}
{{- end }} {{- end }}
{{- partial "shortcodes/expand.html" (dict {{- partial "shortcodes/expand.html" (dict
"context" .Page "page" .Page
"content" .Inner "content" .Inner
"open" (.Get "open" | default (.Get 1)) "open" (.Get "open" | default (.Get 1))
"title" (.Get "title" | default (.Get 0)) "title" (.Get "title" | default (.Get 0))

View file

@ -24,7 +24,7 @@
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- partial "shortcodes/highlight.html" (dict {{- partial "shortcodes/highlight.html" (dict
"context" .Page "page" .Page
"attributes" $attributes "attributes" $attributes
"content" $content "content" $content
"options" $options "options" $options

View file

@ -1,5 +1,5 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- partial "shortcodes/icon.html" (dict {{- partial "shortcodes/icon.html" (dict
"context" .Page "page" .Page
"icon" (.Get "icon" | default (.Get 0)) "icon" (.Get "icon" | default (.Get 0))
) }} ) }}

View file

@ -1,5 +1,5 @@
{{- partial "shortcodes/include.html" (dict {{- partial "shortcodes/include.html" (dict
"context" .Page "page" .Page
"file" (.Get "file" | default (.Get 0)) "file" (.Get "file" | default (.Get 0))
"hidefirstheading" (.Get "hidefirstheading" | default (.Get 1)) "hidefirstheading" (.Get "hidefirstheading" | default (.Get 1))
) }} ) }}

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- partial "shortcodes/math.html" (dict {{- partial "shortcodes/math.html" (dict
"context" .Page "page" .Page
"content" .Inner "content" .Inner
"align" (.Get "align") "align" (.Get "align")
) }} ) }}

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- partial "shortcodes/mermaid.html" (dict {{- partial "shortcodes/mermaid.html" (dict
"context" .Page "page" .Page
"content" .Inner "content" .Inner
"align" (.Get "align") "align" (.Get "align")
"zoom" (.Get "zoom") "zoom" (.Get "zoom")

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- partial "shortcodes/notice.html" (dict {{- partial "shortcodes/notice.html" (dict
"context" .Page "page" .Page
"color" (.Get "color") "color" (.Get "color")
"content" .Inner "content" .Inner
"icon" (.Get "icon" | default (.Get 2)) "icon" (.Get "icon" | default (.Get 2))

View file

@ -6,7 +6,7 @@
{{- $id = "" }} {{- $id = "" }}
{{- end }} {{- end }}
{{- partial "shortcodes/openapi.html" (dict {{- partial "shortcodes/openapi.html" (dict
"context" .Page "page" .Page
"src" (.Get "src") "src" (.Get "src")
"id" $id "id" $id
) }} ) }}

View file

@ -1,4 +1,4 @@
{{- partial "shortcodes/siteparam.html" (dict {{- partial "shortcodes/siteparam.html" (dict
"context" .Page "page" .Page
"name" (.Get "name" | default (.Get 0)) "name" (.Get "name" | default (.Get 0))
) }} ) }}

View file

@ -6,7 +6,7 @@
{{- $id = "" }} {{- $id = "" }}
{{- end }} {{- end }}
{{- partial "shortcodes/swagger.html" (dict {{- partial "shortcodes/swagger.html" (dict
"context" .Page "page" .Page
"src" (.Get "src") "src" (.Get "src")
"id" $id "id" $id
) }} ) }}

View file

@ -22,7 +22,7 @@
{{- else }} {{- else }}
{{- $c:=""}}{{/* if no containing tabs shortcode is present, we display this tab as single */}} {{- $c:=""}}{{/* if no containing tabs shortcode is present, we display this tab as single */}}
{{- partial "shortcodes/tabs.html" (dict {{- partial "shortcodes/tabs.html" (dict
"context" .Page "page" .Page
"color" "" "color" ""
"content" $tabs "content" $tabs
"groupid" "" "groupid" ""

View file

@ -9,7 +9,7 @@
{{- $title := (.Get "title") }} {{- $title := (.Get "title") }}
{{- $tabs := (.Scratch.Get "tabs") }} {{- $tabs := (.Scratch.Get "tabs") }}
{{- partial "shortcodes/tabs.html" (dict {{- partial "shortcodes/tabs.html" (dict
"context" .Page "page" .Page
"color" $color "color" $color
"content" $tabs "content" $tabs
"groupid" $groupid "groupid" $groupid