From 77f41e96074f28c4431a9ae522c1aa2804d9f4e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Thu, 18 May 2023 14:01:50 +0200 Subject: [PATCH] shortcode: make .context always a page #527 --- .../layouts/partials/shortcodes/piratify.html | 8 ++++---- exampleSite/layouts/shortcodes/piratify.html | 2 +- layouts/partials/shortcodes/attachments.html | 14 +++++++------- layouts/partials/shortcodes/children.html | 8 ++++---- layouts/partials/shortcodes/expand.html | 2 +- layouts/partials/shortcodes/link.html | 4 ++-- layouts/partials/shortcodes/math.html | 2 +- layouts/partials/shortcodes/mermaid.html | 4 ++-- layouts/partials/shortcodes/openapi.html | 6 +++--- layouts/partials/shortcodes/swagger.html | 2 +- layouts/shortcodes/attachments.html | 2 +- layouts/shortcodes/badge.html | 2 +- layouts/shortcodes/button.html | 2 +- layouts/shortcodes/children.html | 2 +- layouts/shortcodes/expand.html | 2 +- layouts/shortcodes/icon.html | 2 +- layouts/shortcodes/include.html | 2 +- layouts/shortcodes/math.html | 2 +- layouts/shortcodes/mermaid.html | 2 +- layouts/shortcodes/notice.html | 2 +- layouts/shortcodes/openapi.html | 2 +- layouts/shortcodes/siteparam.html | 2 +- layouts/shortcodes/swagger.html | 2 +- layouts/shortcodes/tabs.html | 2 +- 24 files changed, 40 insertions(+), 40 deletions(-) diff --git a/exampleSite/layouts/partials/shortcodes/piratify.html b/exampleSite/layouts/partials/shortcodes/piratify.html index c983805691..4098182259 100644 --- a/exampleSite/layouts/partials/shortcodes/piratify.html +++ b/exampleSite/layouts/partials/shortcodes/piratify.html @@ -3,12 +3,12 @@ {{- $pagefield := cond (ne $content nil) nil (.pagefield | default "Content") }} {{- $writenotice := cond (ne .writenotice nil) .writenotice false }} {{- $langtrg := "pir" }} -{{- $langsrc := cond (eq $context.Page.Lang $langtrg) (.langsrc | default "en") $context.Page.Lang }} +{{- $langsrc := cond (eq $context.Lang $langtrg) (.langsrc | default "en") $context.Lang }} {{- $baseURL := urls.Parse site.BaseURL }} {{- $baseURLpath := $baseURL.Path | default "/" }} {{- $l := "" }} {{- $c := "" }} -{{- range $context.Page.AllTranslations }} +{{- range $context.AllTranslations }} {{- if eq .Language.Lang $langsrc }} {{- $l = .RelPermalink }} {{- if ne $content nil }} @@ -21,10 +21,10 @@ {{- break }} {{- end }} {{- end }} -{{- if eq $context.Page.Lang $langtrg }} +{{- if eq $context.Lang $langtrg }} {{- if $writenotice }} {{- partial "shortcodes/notice.html" (dict - "context" . + "context" $context "content" "

Fello' pirrrates, grog made us dizzy! Be awarrre some stuff may not work in this trrranslat'n. Like see'n Merrrmaids, do'n math or chemistrrry, writ'n docs and stuff.

\n" "icon" "skull-crossbones" "style" "warning" diff --git a/exampleSite/layouts/shortcodes/piratify.html b/exampleSite/layouts/shortcodes/piratify.html index f9cf6c7f85..09e409a670 100644 --- a/exampleSite/layouts/shortcodes/piratify.html +++ b/exampleSite/layouts/shortcodes/piratify.html @@ -1,5 +1,5 @@ {{- partial "shortcodes/piratify.html" (dict - "context" . + "context" .Page "pagefield" "Content" "writenotice" (.Get "writenotice" | default (.Get 0)) ) }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/attachments.html b/layouts/partials/shortcodes/attachments.html index c05809310d..49ac7c7dd5 100644 --- a/layouts/partials/shortcodes/attachments.html +++ b/layouts/partials/shortcodes/attachments.html @@ -21,23 +21,23 @@ {{- end }} {{- $sort := .sort | default "asc" }} {{- $pattern := .pattern | default "" }} -{{- $defaultUrlPrefix := strings.TrimRight "/" $context.Page.RelPermalink }} +{{- $defaultUrlPrefix := strings.TrimRight "/" $context.RelPermalink }} {{- if .IsTranslated -}} {{- $defaultLanguage := (index $context.Site.Home.AllTranslations 0).Lang }} - {{- $defaultLanguagePage := index (where $context.Page.AllTranslations "Language.Lang" $defaultLanguage) 0 }} + {{- $defaultLanguagePage := index (where $context.AllTranslations "Language.Lang" $defaultLanguage) 0 }} {{- $defaultUrlPrefix = strings.TrimRight "/" $defaultLanguagePage.RelPermalink }} {{- end }} -{{- $urlPrefix := strings.TrimRight "/" $context.Page.RelPermalink }} +{{- $urlPrefix := strings.TrimRight "/" $context.RelPermalink }} {{- with $context }}
{{ if $icon }}{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | markdownify }}
-{{- .Page.Store.Set "hasOpenapi" true }} +{{- .Store.Set "hasOpenapi" true }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/swagger.html b/layouts/partials/shortcodes/swagger.html index 6af9af941e..d95bbc3cb7 100644 --- a/layouts/partials/shortcodes/swagger.html +++ b/layouts/partials/shortcodes/swagger.html @@ -1,4 +1,4 @@ -{{ warnf "DEPRECATED: Use shortcode openapi instead of swagger in %q" .context.Page.File.Path }} +{{ warnf "DEPRECATED: Use shortcode openapi instead of swagger in %q" .context.File.Path }} {{- partial "shortcodes/openapi.html" (dict "context" .context "src" .src diff --git a/layouts/shortcodes/attachments.html b/layouts/shortcodes/attachments.html index 2b09181064..34a7ee7157 100644 --- a/layouts/shortcodes/attachments.html +++ b/layouts/shortcodes/attachments.html @@ -1,6 +1,6 @@ {{- $_hugo_config := `{ "version": 1 }` }} {{- partial "shortcodes/attachments.html" (dict - "context" . + "context" .Page "color" (.Get "color") "content" .Inner "icon" (.Get "icon") diff --git a/layouts/shortcodes/badge.html b/layouts/shortcodes/badge.html index 65900f4423..b3c4163c03 100644 --- a/layouts/shortcodes/badge.html +++ b/layouts/shortcodes/badge.html @@ -1,6 +1,6 @@ {{- $_hugo_config := `{ "version": 1 }` }} {{- partial "shortcodes/badge.html" (dict - "context" . + "context" .Page "color" (.Get "color") "content" .Inner "icon" (.Get "icon") diff --git a/layouts/shortcodes/button.html b/layouts/shortcodes/button.html index 4bf82bba6b..1e9941d1ab 100644 --- a/layouts/shortcodes/button.html +++ b/layouts/shortcodes/button.html @@ -1,6 +1,6 @@ {{- $_hugo_config := `{ "version": 1 }` }} {{- partial "shortcodes/button.html" (dict - "context" . + "context" .Page "color" (.Get "color") "content" .Inner "href" (.Get "href") diff --git a/layouts/shortcodes/children.html b/layouts/shortcodes/children.html index 23c053ff51..d000514859 100644 --- a/layouts/shortcodes/children.html +++ b/layouts/shortcodes/children.html @@ -1,6 +1,6 @@ {{- $_hugo_config := `{ "version": 1 }` }} {{- partial "shortcodes/children.html" (dict - "context" . + "context" .Page "containerstyle" (.Get "containerstyle") "description" (.Get "description") "depth" (.Get "depth") diff --git a/layouts/shortcodes/expand.html b/layouts/shortcodes/expand.html index f4f4fe407a..7a1d7c2bc5 100644 --- a/layouts/shortcodes/expand.html +++ b/layouts/shortcodes/expand.html @@ -7,7 +7,7 @@ {{- $id = .Ordinal }} {{- end }} {{- partial "shortcodes/expand.html" (dict - "context" . + "context" .Page "content" .Inner "open" (.Get "open" | default (.Get 1)) "title" (.Get "title" | default (.Get 0)) diff --git a/layouts/shortcodes/icon.html b/layouts/shortcodes/icon.html index 09b0140336..80e60fd99a 100644 --- a/layouts/shortcodes/icon.html +++ b/layouts/shortcodes/icon.html @@ -1,5 +1,5 @@ {{- $_hugo_config := `{ "version": 1 }` }} {{- partial "shortcodes/icon.html" (dict - "context" . + "context" .Page "icon" (.Get "icon" | default (.Get 0)) ) }} \ No newline at end of file diff --git a/layouts/shortcodes/include.html b/layouts/shortcodes/include.html index a48125d07c..c9901a5cd6 100644 --- a/layouts/shortcodes/include.html +++ b/layouts/shortcodes/include.html @@ -1,5 +1,5 @@ {{- partial "shortcodes/include.html" (dict - "context" . + "context" .Page "file" (.Get "file" | default (.Get 0)) "hidefirstheading" (.Get "hidefirstheading" | default (.Get 1)) ) }} \ No newline at end of file diff --git a/layouts/shortcodes/math.html b/layouts/shortcodes/math.html index 103c71ff2c..1e037bac43 100644 --- a/layouts/shortcodes/math.html +++ b/layouts/shortcodes/math.html @@ -1,6 +1,6 @@ {{- $_hugo_config := `{ "version": 1 }` }} {{- partial "shortcodes/math.html" (dict - "context" . + "context" .Page "content" .Inner "align" (.Get "align") ) }} \ No newline at end of file diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html index 03918da815..1ff05523e3 100644 --- a/layouts/shortcodes/mermaid.html +++ b/layouts/shortcodes/mermaid.html @@ -1,6 +1,6 @@ {{- $_hugo_config := `{ "version": 1 }` }} {{- partial "shortcodes/mermaid.html" (dict - "context" . + "context" .Page "content" .Inner "align" (.Get "align") "zoom" (.Get "zoom") diff --git a/layouts/shortcodes/notice.html b/layouts/shortcodes/notice.html index 8ec82a74fc..e65d9be16f 100644 --- a/layouts/shortcodes/notice.html +++ b/layouts/shortcodes/notice.html @@ -1,6 +1,6 @@ {{- $_hugo_config := `{ "version": 1 }` }} {{- partial "shortcodes/notice.html" (dict - "context" . + "context" .Page "color" (.Get "color") "content" .Inner "icon" (.Get "icon" | default (.Get 2)) diff --git a/layouts/shortcodes/openapi.html b/layouts/shortcodes/openapi.html index bc58b2b2fa..3842857f5b 100644 --- a/layouts/shortcodes/openapi.html +++ b/layouts/shortcodes/openapi.html @@ -6,7 +6,7 @@ {{- $id = .Ordinal }} {{- end }} {{- partial "shortcodes/openapi.html" (dict - "context" . + "context" .Page "src" (.Get "src") "id" $id ) }} \ No newline at end of file diff --git a/layouts/shortcodes/siteparam.html b/layouts/shortcodes/siteparam.html index 3f8e226496..8aa20b1fe2 100644 --- a/layouts/shortcodes/siteparam.html +++ b/layouts/shortcodes/siteparam.html @@ -1,4 +1,4 @@ {{- partial "shortcodes/siteparam.html" (dict - "context" . + "context" .Page "name" (.Get "name" | default (.Get 0)) ) }} \ No newline at end of file diff --git a/layouts/shortcodes/swagger.html b/layouts/shortcodes/swagger.html index 4fbc10af91..c96b2b424d 100644 --- a/layouts/shortcodes/swagger.html +++ b/layouts/shortcodes/swagger.html @@ -6,7 +6,7 @@ {{- $id = .Ordinal }} {{- end }} {{- partial "shortcodes/swagger.html" (dict - "context" . + "context" .Page "src" (.Get "src") "id" $id ) }} \ No newline at end of file diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index 7fbe50ee08..157c950723 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -1,5 +1,5 @@ {{- partial "shortcodes/tabs.html" (dict - "context" . + "context" .Page "content" .Inner "groupid" ((.Get "groupid") | default (.Get "groupId")) "tabs" (.Scratch.Get "tabs")