From 64e148ab6f0ee40d153e256dd0b86f6cb8175921 Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 29 Jan 2023 10:56:57 -0800 Subject: [PATCH] Assign template context to var --- layouts/_default/baseof.html | 30 ++++++++-------- layouts/_default/home.html | 20 ++++++----- layouts/_default/home.json | 10 +++--- layouts/_default/list.html | 6 ++-- layouts/_default/rss.xml | 30 ++++++++-------- layouts/_default/single.html | 6 ++-- layouts/_default/taxonomy.html | 8 +++-- layouts/_default/term.html | 6 ++-- layouts/partials/paige/a.html | 10 +++--- layouts/partials/paige/about.html | 14 ++++---- layouts/partials/paige/article.html | 8 +++-- layouts/partials/paige/comments.html | 14 ++++---- layouts/partials/paige/content.html | 8 +++-- layouts/partials/paige/description.html | 6 ++-- layouts/partials/paige/figure.html | 28 ++++++++------- layouts/partials/paige/footer.html | 2 ++ layouts/partials/paige/func-authors.html | 6 ++-- layouts/partials/paige/func-resource.html | 5 +-- layouts/partials/paige/func-title.html | 24 +++++++------ layouts/partials/paige/head.html | 14 ++++---- layouts/partials/paige/header.html | 8 +++-- layouts/partials/paige/image-figure.html | 42 ++++++++++++----------- layouts/partials/paige/img.html | 40 +++++++++++---------- layouts/partials/paige/link.html | 14 ++++---- layouts/partials/paige/links.html | 6 ++-- layouts/partials/paige/metadata.html | 8 +++-- layouts/partials/paige/metas.html | 12 ++++--- layouts/partials/paige/pages.html | 40 +++++++++++---------- layouts/partials/paige/script.html | 18 +++++----- layouts/partials/paige/search.html | 4 ++- layouts/partials/paige/title.html | 8 +++-- layouts/partials/paige/toc.html | 6 ++-- 32 files changed, 262 insertions(+), 199 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 770b0542..bcb43241 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,35 +1,37 @@ +{{ $page := . }} + -{{ $rtl := eq .Language.LanguageDirection "rtl" }} -{{ $lang := .Site.LanguageCode | default .Site.Language.Lang }} - - {{ partial "paige/head.html" . }} - {{ partial "paige/body.html" . }} +{{ $rtl := eq $page.Language.LanguageDirection "rtl" }} +{{ $lang := $page.Site.LanguageCode | default $page.Site.Language.Lang }} + + {{ partial "paige/head.html" $page }} + {{ partial "paige/body.html" $page }} {{ if templates.Exists "partials/paige/body-first.html" }} - {{ partial "paige/body-first.html" . }} + {{ partial "paige/body-first.html" $page }} {{ end }}
- {{ partial "paige/header.html" . }} + {{ partial "paige/header.html" $page }}
{{ if templates.Exists "partials/paige/main-first.html" }} - {{ partial "paige/main-first.html" . }} + {{ partial "paige/main-first.html" $page }} {{ end }} - {{ block "main" . }}{{ end }} + {{ block "main" $page }}{{ end }} {{ if templates.Exists "partials/paige/main-last.html" }} - {{ partial "paige/main-last.html" . }} + {{ partial "paige/main-last.html" $page }} {{ end }}
- {{ partial "paige/footer.html" . }} + {{ partial "paige/footer.html" $page }}
- {{ partial "paige/scripts.html" . }} + {{ partial "paige/scripts.html" $page }} {{ if templates.Exists "partials/paige/body-last.html" }} - {{ partial "paige/body-last.html" . }} + {{ partial "paige/body-last.html" $page }} {{ end }} -{{ if not .Site.Params.paige.hide_theme_comment }} +{{ if not $page.Site.Params.paige.hide_theme_comment }} {{ printf "" | safeHTML }} {{ end }} diff --git a/layouts/_default/home.html b/layouts/_default/home.html index 3cbe6df4..58c91889 100644 --- a/layouts/_default/home.html +++ b/layouts/_default/home.html @@ -1,14 +1,16 @@ {{ define "main" }} +{{ $page := . }} +
- {{ partial "paige/metadata.html" . }} + {{ partial "paige/metadata.html" $page }}
- {{ if .Params.image_url }} + {{ if $page.Params.image_url }} {{ $class := "mw-100 rounded-4 shadow" }} - {{ if .Params.image_stretch }} + {{ if $page.Params.image_stretch }} {{ $class = "rounded-4 shadow w-100" }} {{ end }} {{ $style := "height: 20rem" }} - {{ if .Params.image_stretch }} + {{ if $page.Params.image_stretch }} {{ $style = "height: 20rem; object-fit: cover" }} {{ end }}

@@ -22,10 +24,10 @@ ) }}

{{ end }} - {{ with .Params.greeting }} + {{ with $page.Params.greeting }}

{{ . | markdownify }}

{{ end }} - {{ with .Params.blurb }} + {{ with $page.Params.blurb }}
@@ -35,8 +37,8 @@
{{ end }}
- {{ partial "paige/toc.html" . }} - {{ partial "paige/content.html" . }} - {{ partial "paige/social.html" . }} + {{ partial "paige/toc.html" $page }} + {{ partial "paige/content.html" $page }} + {{ partial "paige/social.html" $page }}
{{ end }} diff --git a/layouts/_default/home.json b/layouts/_default/home.json index 8f83efbc..899e54f3 100644 --- a/layouts/_default/home.json +++ b/layouts/_default/home.json @@ -1,6 +1,8 @@ -{{- $.Scratch.Add "index" slice -}} -{{- range where .Site.RegularPages "Params.paige.hide_search" "ne" true -}} -{{- $.Scratch.Add "index" (dict +{{- $page := . -}} + +{{- $page.Scratch.Add "index" slice -}} +{{- range where $page.Site.RegularPages "Params.paige.hide_search" "ne" true -}} +{{- $page.Scratch.Add "index" (dict "categories" .Params.categories "date" .PublishDate "description" (.Description | markdownify | plainify | htmlUnescape) @@ -10,4 +12,4 @@ "text" (strings.TrimRight " " (replace (.Plain | htmlUnescape) "\n" " ")) "title" (.Title | markdownify | plainify | htmlUnescape)) -}} {{- end -}} -{{- $.Scratch.Get "index" | jsonify -}} +{{- $page.Scratch.Get "index" | jsonify -}} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 662661e7..9d43caf9 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,6 +1,8 @@ {{ define "main" }} +{{ $page := . }} + {{ if not .Params.paige.show_full_pages }} -{{ partial "paige/article.html" . }} +{{ partial "paige/article.html" $page }} {{ end }} -{{ partial "paige/pages.html" . }} +{{ partial "paige/pages.html" $page }} {{ end }} diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 42155fa8..62801efb 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -1,43 +1,45 @@ -{{ $item := . }} -{{ if .IsHome }} -{{ $item = .Site }} +{{ $page := . }} + +{{ $item := $page }} +{{ if $page.IsHome }} +{{ $item = $page.Site }} {{ end }} {{ $pages := slice }} -{{ if or $.IsHome $.IsSection }} +{{ if or $page.IsHome $page.IsSection }} {{ $pages = $item.RegularPages }} {{ else }} {{ $pages = $item.Pages }} {{ end }} -{{ $limit := .Site.Config.Services.RSS.Limit }} +{{ $limit := $page.Site.Config.Services.RSS.Limit }} {{ if ge $limit 1 }} {{ $pages = $pages | first $limit }} {{ end }} {{ $pages = where $pages "Params.paige.hide_rss" "ne" true }} -{{ $title := partial "paige/func-title.html" . }} +{{ $title := partial "paige/func-title.html" $page }} {{ printf "" | safeHTML }} - {{ with .OutputFormats.Get "RSS" }} + {{ with $page.OutputFormats.Get "RSS" }} {{ printf `` .Permalink .MediaType | safeHTML }} {{ end }} - {{ with .Site.Copyright }} + {{ with $page.Site.Copyright }} {{ . }} {{ end }} {{ with $title }}{{ . }}{{ else }}Recent content{{ end }} - {{ with .Site.LanguageCode | default .Site.Language.Lang }} + {{ with $page.Site.LanguageCode | default .Site.Language.Lang }} {{ . }} {{ end }} - {{ if and .Date (not .Date.IsZero) }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ if and $page.Date (not $page.Date.IsZero) }} + {{ $page.Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} {{ end }} - {{ .Permalink }} - {{ with .Site.Params.paige.rss.managing_editor }} + {{ $page.Permalink }} + {{ with $page.Site.Params.paige.rss.managing_editor }} {{ . }} {{ end }} {{ with $title }} {{ . }} {{ end }} - {{ with .Site.Params.paige.rss.web_master }} + {{ with $page.Site.Params.paige.rss.web_master }} {{ . }} {{ end }} {{ range $pages }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 5cf5269e..fc973814 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,4 +1,6 @@ {{ define "main" }} -{{ partial "paige/article.html" . }} -{{ partial "paige/comments.html" . }} +{{ $page := . }} + +{{ partial "paige/article.html" $page }} +{{ partial "paige/comments.html" $page }} {{ end }} diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index 008a6f00..93e34c22 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -1,9 +1,11 @@ {{ define "main" }} -{{ partial "paige/article.html" . }} -{{ if .Pages }} +{{ $page := . }} + +{{ partial "paige/article.html" $page }} +{{ if $page.Pages }}
    - {{ range (sort .Pages "Title") }} + {{ range (sort $page.Pages "Title") }}
  • {{ .Title | markdownify }}
  • diff --git a/layouts/_default/term.html b/layouts/_default/term.html index 8235f475..40c30434 100644 --- a/layouts/_default/term.html +++ b/layouts/_default/term.html @@ -1,4 +1,6 @@ {{ define "main" }} -{{ partial "paige/article.html" . }} -{{ partial "paige/pages.html" . }} +{{ $page := . }} + +{{ partial "paige/article.html" $page }} +{{ partial "paige/pages.html" $page }} {{ end }} diff --git a/layouts/partials/paige/a.html b/layouts/partials/paige/a.html index 942b137d..06cbbaad 100644 --- a/layouts/partials/paige/a.html +++ b/layouts/partials/paige/a.html @@ -1,6 +1,8 @@ -{{ $class := .class }} -{{ $content := .content }} -{{ $href := .href }} -{{ $style := .style }} +{{ $params := . }} + +{{ $class := $params.class }} +{{ $content := $params.content }} +{{ $href := $params.href }} +{{ $style := $params.style }} {{ $content }} diff --git a/layouts/partials/paige/about.html b/layouts/partials/paige/about.html index 2dd3f5d0..7cfe708c 100644 --- a/layouts/partials/paige/about.html +++ b/layouts/partials/paige/about.html @@ -1,14 +1,16 @@ -{{ $authors := cond (.Param "paige.page.authors.hide" | not) (partial "paige/func-authors.html" .) "" }} -{{ $authorsclass := .Param "paige.page.authors.class" | default "text-center text-secondary" }} +{{ $page := . }} + +{{ $authors := cond ($page.Param "paige.page.authors.hide" | not) (partial "paige/func-authors.html" $page) "" }} +{{ $authorsclass := $page.Param "paige.page.authors.class" | default "text-center text-secondary" }} {{ $gap := "mb-0" }} -{{ $date := cond (.Param "paige.page.date.hide" | not) .PublishDate "" }} -{{ $dateclass := .Param "paige.page.date.class" | default "text-center text-secondary" }} +{{ $date := cond ($page.Param "paige.page.date.hide" | not) $page.PublishDate "" }} +{{ $dateclass := $page.Param "paige.page.date.class" | default "text-center text-secondary" }} {{ with $authors }}

    {{ . }}

    {{ end }} -{{ if $date }} +{{ with $date }}

    - +

    {{ end }} diff --git a/layouts/partials/paige/article.html b/layouts/partials/paige/article.html index 1302e9dc..e3dd7ba3 100644 --- a/layouts/partials/paige/article.html +++ b/layouts/partials/paige/article.html @@ -1,7 +1,9 @@ +{{ $page := . }} +
    - {{ partial "paige/metadata.html" . }} - {{ partial "paige/toc.html" . }} - {{ partial "paige/content.html" . }} + {{ partial "paige/metadata.html" $page }} + {{ partial "paige/toc.html" $page }} + {{ partial "paige/content.html" $page }}
    diff --git a/layouts/partials/paige/comments.html b/layouts/partials/paige/comments.html index 643028fc..28f6ba44 100644 --- a/layouts/partials/paige/comments.html +++ b/layouts/partials/paige/comments.html @@ -1,3 +1,5 @@ +{{ $page := . }} + {{ template "_internal/disqus.html" . }} {{ if site.Params.paige.comments.cactus }}
    @@ -10,7 +12,7 @@ defaultHomeserverUrl: "https://matrix.cactus.chat:8448", serverName: "cactus.chat", siteName: {{ site.Params.paige.comments.cactus.account_id }}, - commentSectionId: {{ .RelPermalink }} + commentSectionId: {{ $page.RelPermalink }} }) @@ -30,7 +32,7 @@ var __semio__params = { graphcommentId: {{ site.Params.paige.comments.graphcomment.account_id }}, behaviour: { - uid: {{ .RelPermalink }} + uid: {{ $page.RelPermalink }} } }; function __semio__onload() { @@ -52,7 +54,7 @@ var HYVOR_TALK_WEBSITE = {{ site.Params.paige.comments.hyvor.account_id }}; var HYVOR_TALK_CONFIG = { url: false, - id: {{ .RelPermalink }} + id: {{ $page.RelPermalink }} }; @@ -63,8 +65,8 @@
    @@ -105,7 +107,7 @@ diff --git a/layouts/partials/paige/content.html b/layouts/partials/paige/content.html index a270b85b..41a9ce29 100644 --- a/layouts/partials/paige/content.html +++ b/layouts/partials/paige/content.html @@ -1,8 +1,10 @@ -{{ $class := .Param "paige.page.content.class" }} +{{ $page := . }} + +{{ $class := $page.Param "paige.page.content.class" }} {{ $content := "" }} -{{ if .Param "paige.page.title.hide" | not }} - {{ $content = cond (.Scratch.Get "paige_show_full_pages" | not | not) .Content (.Content | replaceRE `()` `${1}#${3}` | safeHTML) }} +{{ if $page.Param "paige.page.title.hide" | not }} + {{ $content = cond ($page.Scratch.Get "paige_show_full_pages" | not | not) $page.Content ($page.Content | replaceRE `()` `${1}#${3}` | safeHTML) }} {{ end }} {{ with $content }} diff --git a/layouts/partials/paige/description.html b/layouts/partials/paige/description.html index ca90949a..7d0bef70 100644 --- a/layouts/partials/paige/description.html +++ b/layouts/partials/paige/description.html @@ -1,5 +1,7 @@ -{{ $class := .Param "paige.page.description.class" | default "lead text-center" }} -{{ $description := cond (.Param "paige.page.description.hide" | not) (.Description | markdownify) "" }} +{{ $page := . }} + +{{ $class := $page.Param "paige.page.description.class" | default "lead text-center" }} +{{ $description := cond ($page.Param "paige.page.description.hide" | not) ($page.Description | markdownify) "" }} {{ with $description }}

    {{ . }}

    diff --git a/layouts/partials/paige/figure.html b/layouts/partials/paige/figure.html index 6afcc0e4..36d9d0ae 100644 --- a/layouts/partials/paige/figure.html +++ b/layouts/partials/paige/figure.html @@ -1,16 +1,18 @@ -{{ $caption := .caption | markdownify }} -{{ $compact := .compact }} -{{ $content := .content | markdownify }} -{{ $float := .float }} -{{ $gap := .gap }} -{{ $height := .height }} -{{ $horizontal := .horizontal | default "center" }} -{{ $maxheight := .maxheight }} -{{ $maxwidth := .maxwidth }} -{{ $number := .number }} -{{ $numbered := .numbered }} -{{ $vertical := .vertical | default "center" }} -{{ $width := .width }} +{{ $params := . }} + +{{ $caption := $params.caption | markdownify }} +{{ $compact := $params.compact }} +{{ $content := $params.content | markdownify }} +{{ $float := $params.float }} +{{ $gap := $params.gap }} +{{ $height := $params.height }} +{{ $horizontal := $params.horizontal | default "center" }} +{{ $maxheight := $params.maxheight }} +{{ $maxwidth := $params.maxwidth }} +{{ $number := $params.number }} +{{ $numbered := $params.numbered }} +{{ $vertical := $params.vertical | default "center" }} +{{ $width := $params.width }} {{ $heightish := or $maxheight $height }} {{ $showcaption := $caption }} diff --git a/layouts/partials/paige/footer.html b/layouts/partials/paige/footer.html index d1c5bf02..121aa77c 100644 --- a/layouts/partials/paige/footer.html +++ b/layouts/partials/paige/footer.html @@ -1,3 +1,5 @@ +{{ $page := . }} + {{ $copyright := site.Copyright }} {{ $first := templates.Exists "partials/paige/footer-first.html" }} {{ $last := templates.Exists "partials/paige/footer-last.html" }} diff --git a/layouts/partials/paige/func-authors.html b/layouts/partials/paige/func-authors.html index f573a509..c69e4d94 100644 --- a/layouts/partials/paige/func-authors.html +++ b/layouts/partials/paige/func-authors.html @@ -1,9 +1,11 @@ +{{ $page := . }} + {{ $result := "" }} -{{ if .Params.authors }} +{{ if $page.Params.authors }} {{ $names := slice }} - {{ range .Params.authors }} + {{ range $page.Params.authors }} {{ if eq (printf "%T" .) "string" }} {{ $names = $names | append (index site.Params.authors .).name }} {{ else }} diff --git a/layouts/partials/paige/func-resource.html b/layouts/partials/paige/func-resource.html index 54422232..f722f13a 100644 --- a/layouts/partials/paige/func-resource.html +++ b/layouts/partials/paige/func-resource.html @@ -1,7 +1,8 @@ -{{ $page := .page }} -{{ $url := .url }} +{{ $params := . }} +{{ $page := $params.page }} {{ $resource := "" }} +{{ $url := $params.url }} {{ with $page.Resources.GetMatch $url }} {{ $resource = . }} diff --git a/layouts/partials/paige/func-title.html b/layouts/partials/paige/func-title.html index af2ebea8..ef44bbf8 100644 --- a/layouts/partials/paige/func-title.html +++ b/layouts/partials/paige/func-title.html @@ -1,17 +1,19 @@ -{{ $pagetitle := .Title | markdownify | plainify | htmlUnescape }} -{{ $sitetitle := .Site.Title | markdownify | plainify | htmlUnescape }} -{{ $title := "" }} +{{ $page := . }} -{{ if and .Title .Site.Title }} +{{ $pagetitle := $page.Title | markdownify | plainify | htmlUnescape }} +{{ $result := "" }} +{{ $sitetitle := site.Title | markdownify | plainify | htmlUnescape }} + +{{ if and $pagetitle $sitetitle }} {{ if .IsHome }} - {{ $title = $pagetitle }} + {{ $result = $pagetitle }} {{ else }} - {{ $title = printf "%s · %s" $pagetitle $sitetitle }} + {{ $result = printf "%s · %s" $pagetitle $sitetitle }} {{ end }} -{{ else if .Title }} - {{ $title = $pagetitle }} -{{ else if .Site.Title }} - {{ $title = $sitetitle }} +{{ else if $pagetitle }} + {{ $result = $pagetitle }} +{{ else if $sitetitle }} + {{ $result = $sitetitle }} {{ end }} -{{ return $title }} +{{ return $result }} diff --git a/layouts/partials/paige/head.html b/layouts/partials/paige/head.html index 2e23d52f..a85e9b21 100644 --- a/layouts/partials/paige/head.html +++ b/layouts/partials/paige/head.html @@ -1,12 +1,14 @@ +{{ $page := . }} + {{ if templates.Exists "partials/paige/head-first.html" }} - {{ partial "paige/head-first.html" . }} + {{ partial "paige/head-first.html" $page }} {{ end }} - {{ partial "paige/metas.html" . }} - {{ partial "paige/func-title.html" . }} - {{ partial "paige/links.html" . }} - {{ partial "paige/style.html" . }} + {{ partial "paige/metas.html" $page }} + {{ partial "paige/func-title.html" $page }} + {{ partial "paige/links.html" $page }} + {{ partial "paige/style.html" $page }} {{ if templates.Exists "partials/paige/head-last.html" }} - {{ partial "paige/head-last.html" . }} + {{ partial "paige/head-last.html" $page }} {{ end }} diff --git a/layouts/partials/paige/header.html b/layouts/partials/paige/header.html index 54c506af..41ca0a31 100644 --- a/layouts/partials/paige/header.html +++ b/layouts/partials/paige/header.html @@ -1,3 +1,5 @@ +{{ $page := . }} + {{ $first := templates.Exists "partials/paige/header-first.html" }} {{ $last := templates.Exists "partials/paige/header-last.html" }} {{ $menu := site.Menus.main }} @@ -5,13 +7,13 @@ {{ if or $first $last $menu }}
    {{ if $first }} - {{ partial "paige/header-first.html" . }} + {{ partial "paige/header-first.html" $page }} {{ end }} {{ if $menu }} - {{ partial "paige/menu.html" . }} + {{ partial "paige/menu.html" $page }} {{ end }} {{ if $last }} - {{ partial "paige/header-last.html" . }} + {{ partial "paige/header-last.html" $page }} {{ end }}
    {{ end }} diff --git a/layouts/partials/paige/image-figure.html b/layouts/partials/paige/image-figure.html index 71af4db5..4e5b3d04 100644 --- a/layouts/partials/paige/image-figure.html +++ b/layouts/partials/paige/image-figure.html @@ -1,23 +1,25 @@ -{{ $alt := .alt }} -{{ $caption := .caption }} -{{ $compact := .compact }} -{{ $float := .float }} -{{ $height := .height }} -{{ $horizontal := .horizontal }} -{{ $link := .link }} -{{ $maxheight := .maxheight }} -{{ $maxwidth := .maxwidth }} -{{ $method := .method }} -{{ $number := .number }} -{{ $numbered := .numbered }} -{{ $options := .options }} -{{ $page := .page }} -{{ $raw := .raw }} -{{ $resource := .resource }} -{{ $src := .src }} -{{ $title := .title }} -{{ $vertical := .vertical }} -{{ $width := .width }} +{{ $params := . }} + +{{ $alt := $params.alt }} +{{ $caption := $params.caption }} +{{ $compact := $params.compact }} +{{ $float := $params.float }} +{{ $height := $params.height }} +{{ $horizontal := $params.horizontal }} +{{ $link := $params.link }} +{{ $maxheight := $params.maxheight }} +{{ $maxwidth := $params.maxwidth }} +{{ $method := $params.method }} +{{ $number := $params.number }} +{{ $numbered := $params.numbered }} +{{ $options := $params.options }} +{{ $page := $params.page }} +{{ $raw := $params.raw }} +{{ $resource := $params.resource }} +{{ $src := $params.src }} +{{ $title := $params.title }} +{{ $vertical := $params.vertical }} +{{ $width := $params.width }} {{ $content := partial "paige/img.html" (dict "alt" $alt diff --git a/layouts/partials/paige/img.html b/layouts/partials/paige/img.html index cd2476a7..acd73a38 100644 --- a/layouts/partials/paige/img.html +++ b/layouts/partials/paige/img.html @@ -1,22 +1,24 @@ -{{ $alt := .alt }} -{{ $class := .class }} -{{ $crossorigin := .crossorigin | default "anonymous" }} -{{ $fetchpriority := .fetchpriority }} -{{ $fingerprint := .fingerprint | default true }} -{{ $height := .height }} -{{ $loading := .loading | default "lazy" }} -{{ $maxheight := .maxheight }} -{{ $maxwidth := .maxwidth }} -{{ $method := .method }} -{{ $options := .options }} -{{ $page := .page }} -{{ $raw := .raw }} -{{ $referrerpolicy := .referrerpolicy | default "no-referrer" }} -{{ $resource := .resource }} -{{ $src := .src }} -{{ $style := .style }} -{{ $title := .title }} -{{ $width := .width }} +{{ $params := . }} + +{{ $alt := $params.alt }} +{{ $class := $params.class }} +{{ $crossorigin := $params.crossorigin | default "anonymous" }} +{{ $fetchpriority := $params.fetchpriority }} +{{ $fingerprint := $params.fingerprint | default true }} +{{ $height := $params.height }} +{{ $loading := $params.loading | default "lazy" }} +{{ $maxheight := $params.maxheight }} +{{ $maxwidth := $params.maxwidth }} +{{ $method := $params.method }} +{{ $options := $params.options }} +{{ $page := $params.page }} +{{ $raw := $params.raw }} +{{ $referrerpolicy := $params.referrerpolicy | default "no-referrer" }} +{{ $resource := $params.resource }} +{{ $src := $params.src }} +{{ $style := $params.style }} +{{ $title := $params.title }} +{{ $width := $params.width }} {{ $intrinsicheight := $height }} {{ $intrinsicwidth := $width }} diff --git a/layouts/partials/paige/link.html b/layouts/partials/paige/link.html index 7efcb1a0..fc3cd3b6 100644 --- a/layouts/partials/paige/link.html +++ b/layouts/partials/paige/link.html @@ -1,9 +1,11 @@ -{{ $crossorigin := .crossorigin | default "anonymous" }} -{{ $href := .href }} -{{ $integrity := .integrity }} -{{ $page := .page }} -{{ $raw := .raw }} -{{ $referrerpolicy := .referrerpolicy | default "no-referrer" }} +{{ $params := . }} + +{{ $crossorigin := $params.crossorigin | default "anonymous" }} +{{ $href := $params.href }} +{{ $integrity := $params.integrity }} +{{ $page := $params.page }} +{{ $raw := $params.raw }} +{{ $referrerpolicy := $params.referrerpolicy | default "no-referrer" }} {{ if $raw }} {{ $href = relLangURL $href }} diff --git a/layouts/partials/paige/links.html b/layouts/partials/paige/links.html index cb70971e..9b3e8925 100644 --- a/layouts/partials/paige/links.html +++ b/layouts/partials/paige/links.html @@ -1,3 +1,5 @@ +{{ $page := . }} + @@ -18,7 +20,7 @@ "integrity" site.Params.paige.bootstrap.style.link_integrity "raw" site.Params.paige.bootstrap.style.raw ) }} -{{ if or .Params.paige.math (and .Params.paige.show_full_pages (where .Pages "Params.paige.math" "eq" true)) }} +{{ if or $page.Params.paige.math (and $page.Params.paige.show_full_pages (where $page.Pages "Params.paige.math" "eq" true)) }} {{ partial "paige/link.html" (dict "href" (site.Params.paige.math.style.link_href | default "https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/katex.min.css") "integrity" (site.Params.paige.math.style.link_integrity | default "sha256-NJNVfEC6jfEt62wQMafLNT2eI6BaWONXbpkSEVAs3+8=") @@ -26,7 +28,7 @@ ) }} {{ end }} {{ if .AlternativeOutputFormats }} - {{ $title := partial "paige/func-title.html" . }} + {{ $title := partial "paige/func-title.html" $page }} {{ range .AlternativeOutputFormats }} {{ end }} diff --git a/layouts/partials/paige/metadata.html b/layouts/partials/paige/metadata.html index b9d3f0e4..377d39d2 100644 --- a/layouts/partials/paige/metadata.html +++ b/layouts/partials/paige/metadata.html @@ -1,5 +1,7 @@ +{{ $page := . }} + diff --git a/layouts/partials/paige/metas.html b/layouts/partials/paige/metas.html index d4b0c1d2..8ca5f927 100644 --- a/layouts/partials/paige/metas.html +++ b/layouts/partials/paige/metas.html @@ -1,11 +1,13 @@ +{{ $page := . }} + -{{ with partial "paige/func-authors.html" . }} +{{ with partial "paige/func-authors.html" $page }} {{ end }} -{{ with .Description }} +{{ with $page.Description }} {{ end }} -{{ if or .Keywords .Params.tags .Params.categories }} +{{ if or $page.Keywords $page.Params.tags $page.Params.categories }} {{ end }} @@ -14,5 +16,5 @@ {{ end }} -{{ template "_internal/opengraph.html" . }} -{{ template "_internal/twitter_cards.html" . }} +{{ template "_internal/opengraph.html" $page }} +{{ template "_internal/twitter_cards.html" $page }} diff --git a/layouts/partials/paige/pages.html b/layouts/partials/paige/pages.html index e28da5b6..d4ffb39c 100644 --- a/layouts/partials/paige/pages.html +++ b/layouts/partials/paige/pages.html @@ -1,41 +1,43 @@ -{{ if .Pages }} - {{ if .Params.paige.show_full_pages }} - {{ $p := .Paginate .Pages }} +{{ $page := . }} + +{{ if $page.Pages }} + {{ if $page.Params.paige.show_full_pages }} + {{ $p := $page.Paginate $page.Pages }}
    {{ range $p.Pages }} - {{ .Scratch.Set "paige_show_full_pages" true }} - {{ partial "paige/article.html" . }} + {{ $page.Scratch.Set "paige_show_full_pages" true }} + {{ partial "paige/article.html" $page }} {{ end }}
    {{ if or $p.HasPrev $p.HasNext }}
    - {{ partial "paige/pagination.html" . }} + {{ partial "paige/pagination.html" $page }}
    {{ end }} {{ else }} - {{ $p := .Paginate (.Pages.ByDate.Reverse.GroupByDate "January 2006") }} + {{ $p := $page.Paginate ($page.Pages.ByDate.Reverse.GroupByDate "January 2006") }}
    {{ range $p.PageGroups }} - {{ if $.Param "paige.page_list.date_header.hide" | not }} + {{ if $page.Param "paige.page_list.date_header.hide" | not }}

    {{ .Key }}

    {{ end }} {{ range .Pages }} {{ $class := "text-center" }} - {{ $authors := cond ($.Param "paige.page_list.authors.show" | not) "" (partial "paige/func-authors.html" .) }} - {{ $authorsclass := $.Param "paige.page_list.authors.class" | default (print $class " text-secondary") }} - {{ $date := cond ($.Param "paige.page_list.date.show" | not) "" .PublishDate }} - {{ $dateclass := $.Param "paige.page_list.date.class" | default (print $class " text-secondary") }} - {{ $description := cond ($.Param "paige.page_list.description.hide" | not) (.Description | markdownify) "" }} - {{ $descriptionclass := $.Param "paige.page_list.description.class" | default $class }} + {{ $authors := cond ($page.Param "paige.page_list.authors.show" | not) "" (partial "paige/func-authors.html" .) }} + {{ $authorsclass := $page.Param "paige.page_list.authors.class" | default (print $class " text-secondary") }} + {{ $date := cond ($page.Param "paige.page_list.date.show" | not) "" .PublishDate }} + {{ $dateclass := $page.Param "paige.page_list.date.class" | default (print $class " text-secondary") }} + {{ $description := cond ($page.Param "paige.page_list.description.hide" | not) (.Description | markdownify) "" }} + {{ $descriptionclass := $page.Param "paige.page_list.description.class" | default $class }} {{ $flags := slice }} {{ $gap := "mb-0" }} - {{ $summary := cond ($.Param "paige.page_list.summary.show" | not) "" (.Summary | strings.TrimPrefix "

    " | strings.TrimSuffix "

    ") }} - {{ $summaryclass := $.Param "paige.page_list.summary.class" | default $class }} - {{ $title := cond ($.Param "paige.page_list.title.hide" | not) (.Title | markdownify) "" }} - {{ $titleclass := $.Param "paige.page_list.title_class" | default $class }} + {{ $summary := cond ($page.Param "paige.page_list.summary.show" | not) "" (.Summary | strings.TrimPrefix "

    " | strings.TrimSuffix "

    ") }} + {{ $summaryclass := $page.Param "paige.page_list.summary.class" | default $class }} + {{ $title := cond ($page.Param "paige.page_list.title.hide" | not) (.Title | markdownify) "" }} + {{ $titleclass := $page.Param "paige.page_list.title.class" | default $class }} {{ if .Draft }} {{ $flags = $flags | append "paige-draft" "paige-unpublished" }} @@ -78,7 +80,7 @@ {{ if or $p.HasPrev $p.HasNext }}
    - {{ partial "paige/pagination.html" . }} + {{ partial "paige/pagination.html" $page }}
    {{ end }} diff --git a/layouts/partials/paige/script.html b/layouts/partials/paige/script.html index ccc13e9a..52f29351 100644 --- a/layouts/partials/paige/script.html +++ b/layouts/partials/paige/script.html @@ -1,11 +1,13 @@ -{{ $crossorigin := .crossorigin | default "anonymous" }} -{{ $defer := .defer | default "defer" }} -{{ $integrity := .integrity }} -{{ $onload := .onload | safeJS }} -{{ $page := .page }} -{{ $referrerpolicy := .referrerpolicy | default "no-referrer" }} -{{ $raw := .raw }} -{{ $src := .src }} +{{ $params := . }} + +{{ $crossorigin := $params.crossorigin | default "anonymous" }} +{{ $defer := $params.defer | default "defer" }} +{{ $integrity := $params.integrity }} +{{ $onload := $params.onload | safeJS }} +{{ $page := $params.page }} +{{ $referrerpolicy := $params.referrerpolicy | default "no-referrer" }} +{{ $raw := $params.raw }} +{{ $src := $params.src }} {{ if $raw }} {{ $src = relLangURL $src }} diff --git a/layouts/partials/paige/search.html b/layouts/partials/paige/search.html index ffd96329..b34256f1 100644 --- a/layouts/partials/paige/search.html +++ b/layouts/partials/paige/search.html @@ -1,3 +1,5 @@ +{{ $page := . }} +
    @@ -87,7 +89,7 @@ function paigeSearch(queryText) { var done = {}; results.forEach(function (result) { result.result.forEach(function (path) { - if (path === "{{ .RelPermalink }}" || done[path]) { + if (path === "{{ $page.RelPermalink }}" || done[path]) { return; } if (!shown) { diff --git a/layouts/partials/paige/title.html b/layouts/partials/paige/title.html index 23500244..3b61acbd 100644 --- a/layouts/partials/paige/title.html +++ b/layouts/partials/paige/title.html @@ -1,6 +1,8 @@ -{{ $class := .Param "paige.page.title.class" | default "display-5 fw-bold text-center" }} -{{ $title := cond (.Param "paige.page.title.hide" | not) (.Title | markdownify) "" }} +{{ $page := . }} + +{{ $class := $page.Param "paige.page.title.class" | default "display-5 fw-bold text-center" }} +{{ $title := cond ($page.Param "paige.page.title.hide" | not) ($page.Title | markdownify) "" }} {{ if $title }} -

    {{ if .Params.link }}{{ $title }}{{ else }}{{ $title }}{{ end }}{{ if .Scratch.Get "paige_show_full_pages" }}#{{ end }}

    +

    {{ if $page.Params.link }}{{ $title }}{{ else }}{{ $title }}{{ end }}{{ if $page.Scratch.Get "paige_show_full_pages" }}#{{ end }}

    {{ end }} diff --git a/layouts/partials/paige/toc.html b/layouts/partials/paige/toc.html index 882ac1e6..d3e695da 100644 --- a/layouts/partials/paige/toc.html +++ b/layouts/partials/paige/toc.html @@ -1,7 +1,9 @@ -{{ if and .Content .Params.paige.toc (not (eq (.Scratch.Get "paige_show_full_pages") true)) (ne .TableOfContents ``) }} +{{ $page := . }} + +{{ if and $page.Content $page.Params.paige.toc (not (eq ($page.Scratch.Get "paige_show_full_pages") true)) (ne $page.TableOfContents ``) }}
    - {{ .TableOfContents }} + {{ $page.TableOfContents }}
    {{ end }}