From 575cc0ca8c4e5904c7ae77e76db812c52e5f8ed1 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Sun, 27 Mar 2022 18:44:06 +0530 Subject: [PATCH] Use `site` function instead of `.Site` or `$.Site` - The site function provides global access to the same data as the .Site page method. - Current context (`.`) is never considered. --- layouts/_default/archives.html | 2 +- layouts/_default/baseof.html | 4 +- layouts/_default/index.json | 2 +- layouts/_default/list.html | 8 +-- layouts/_default/rss.xml | 22 ++++---- layouts/_default/single.html | 4 +- layouts/_default/terms.html | 2 +- layouts/partials/author.html | 4 +- layouts/partials/breadcrumbs.html | 4 +- layouts/partials/cover.html | 6 +- layouts/partials/edit_post.html | 8 +-- layouts/partials/footer.html | 12 ++-- layouts/partials/head.html | 56 +++++++++---------- layouts/partials/header.html | 30 +++++----- layouts/partials/home_info.html | 4 +- layouts/partials/index_profile.html | 6 +- layouts/partials/post_canonical.html | 4 +- layouts/partials/post_meta.html | 2 +- layouts/partials/templates/opengraph.html | 10 ++-- layouts/partials/templates/schema_json.html | 28 +++++----- layouts/partials/templates/twitter_cards.html | 6 +- layouts/partials/translation_list.html | 4 +- layouts/robots.txt | 2 +- 23 files changed, 115 insertions(+), 115 deletions(-) diff --git a/layouts/_default/archives.html b/layouts/_default/archives.html index 435d2a1..e400e2c 100644 --- a/layouts/_default/archives.html +++ b/layouts/_default/archives.html @@ -11,7 +11,7 @@ {{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} -{{- if .Site.Params.ShowAllPagesInArchive }} +{{- if site.Params.ShowAllPagesInArchive }} {{- $pages = site.RegularPages }} {{- end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 6dfe741..3d13f07 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,5 +1,5 @@ - + {{- partial "head.html" . }} @@ -9,7 +9,7 @@ {{- if (or (ne .Kind `page` ) (eq .Layout `archives`) (eq .Layout `search`)) -}} {{- print "list" -}} {{- end -}} -{{- if eq $.Site.Params.defaultTheme `dark` -}} +{{- if eq site.Params.defaultTheme `dark` -}} {{- print " dark" }} {{- end -}} " id="top"> diff --git a/layouts/_default/index.json b/layouts/_default/index.json index 2c86f7c..feeb437 100644 --- a/layouts/_default/index.json +++ b/layouts/_default/index.json @@ -1,5 +1,5 @@ {{- $.Scratch.Add "index" slice -}} -{{- range .Site.RegularPages -}} +{{- range site.RegularPages -}} {{- if and (not .Params.searchHidden) (ne .Layout `archives`) (ne .Layout `search`) }} {{- $.Scratch.Add "index" (dict "title" .Title "content" .Plain "permalink" .Permalink "summary" .Summary) -}} {{- end }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 0cc1ad9..f4ff6ec 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,6 +1,6 @@ {{- define "main" }} -{{- if (and .Site.Params.profileMode.enabled .IsHome) }} +{{- if (and site.Params.profileMode.enabled .IsHome) }} {{- partial "index_profile.html" . }} {{- else }} {{/* if not profileMode */}} @@ -32,7 +32,7 @@ {{- $paginator := .Paginate $pages }} -{{- if and .IsHome .Site.Params.homeInfoParams (eq $paginator.PageNumber 1) }} +{{- if and .IsHome site.Params.homeInfoParams (eq $paginator.PageNumber 1) }} {{- partial "home_info.html" . }} {{- end }} @@ -41,7 +41,7 @@ {{- $class := "post-entry" }} -{{- $user_preferred := or .Site.Params.disableSpecial1stPost .Site.Params.homeInfoParams }} +{{- $user_preferred := or site.Params.disableSpecial1stPost site.Params.homeInfoParams }} {{- if (and $.IsHome (eq $paginator.PageNumber 1) (eq $index 0) (not $user_preferred)) }} {{- $class = "first-entry" }} {{- else if $term }} @@ -49,7 +49,7 @@ {{- end }}
- {{- $isHidden := (.Site.Params.cover.hidden | default .Site.Params.cover.hiddenInList) }} + {{- $isHidden := (site.Params.cover.hidden | default site.Params.cover.hiddenInList) }} {{- partial "cover.html" (dict "cxt" . "IsHome" true "isHidden" $isHidden) }}

diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index eca41b7..134d50d 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -1,31 +1,31 @@ {{- $pctx := . -}} -{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} +{{- if .IsHome -}}{{ $pctx = site }}{{- end -}} {{- $pages := slice -}} {{- if or $.IsHome $.IsSection -}} {{- $pages = $pctx.RegularPages -}} {{- else -}} {{- $pages = $pctx.Pages -}} {{- end -}} -{{- $limit := .Site.Config.Services.RSS.Limit -}} +{{- $limit := site.Config.Services.RSS.Limit -}} {{- if ge $limit 1 -}} {{- $pages = $pages | first $limit -}} {{- end -}} {{- printf "" | safeHTML }} - {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} + {{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ site.Title }}{{ end }} {{ .Permalink }} - Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} - {{- with $.Site.Params.images }} + Recent content {{ if ne .Title site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ site.Title }} + {{- with site.Params.images }} {{ index . 0 | absURL }} {{ index . 0 | absURL }} {{- end }} - Hugo -- gohugo.io{{ with .Site.LanguageCode }} - {{.}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} + Hugo -- gohugo.io{{ with site.LanguageCode }} + {{.}}{{end}}{{ with site.Author.email }} + {{.}}{{ with site.Author.name }} ({{.}}){{end}}{{end}}{{ with site.Author.email }} + {{.}}{{ with site.Author.name }} ({{.}}){{end}}{{end}}{{ with site.Copyright }} {{.}}{{end}}{{ if not .Date.IsZero }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} {{- with .OutputFormats.Get "RSS" -}} @@ -37,10 +37,10 @@ {{ .Title }} {{ .Permalink }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + {{ with site.Author.email }}{{.}}{{ with site.Author.name }} ({{.}}){{end}}{{end}} {{ .Permalink }} {{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}} - {{- if .Site.Params.ShowFullTextinRSS }} + {{- if site.Params.ShowFullTextinRSS }} {{ (printf "" .Content) | safeHTML }} {{- end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 1d983fd..d313500 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -21,7 +21,7 @@ {{- end }}

- {{- $isHidden := .Params.cover.hidden | default .Site.Params.cover.hiddenInSingle | default .Site.Params.cover.hidden }} + {{- $isHidden := .Params.cover.hidden | default site.Params.cover.hiddenInSingle | default site.Params.cover.hidden }} {{- partial "cover.html" (dict "cxt" . "IsHome" false "isHidden" $isHidden) }} {{- if (.Param "ShowToc") }} {{- partial "toc.html" . }} @@ -46,7 +46,7 @@ {{- if (.Param "ShowPostNavLinks") }} {{- partial "post_nav_links.html" . }} {{- end }} - {{- if (and .Site.Params.ShowShareButtons (ne .Params.disableShare true)) }} + {{- if (and site.Params.ShowShareButtons (ne .Params.disableShare true)) }} {{- partial "share_icons.html" . -}} {{- end }} diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index d5a9e66..6fd2654 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -16,7 +16,7 @@ {{- range $key, $value := .Data.Terms.Alphabetical }} {{- $name := .Name }} {{- $count := .Count }} - {{- with $.Site.GetPage (printf "/%s/%s" $type $name) }} + {{- with site.GetPage (printf "/%s/%s" $type $name) }}
  • {{ .Name }} {{ $count }}
  • diff --git a/layouts/partials/author.html b/layouts/partials/author.html index 4582b12..8f2758f 100644 --- a/layouts/partials/author.html +++ b/layouts/partials/author.html @@ -1,5 +1,5 @@ -{{- if or .Params.author .Site.Params.author }} -{{- $author := (.Params.author | default .Site.Params.author) }} +{{- if or .Params.author site.Params.author }} +{{- $author := (.Params.author | default site.Params.author) }} {{- $author_type := (printf "%T" $author) }} {{- if (or (eq $author_type "[]string") (eq $author_type "[]interface {}")) }} {{- (delimit $author ", " ) }} diff --git a/layouts/partials/breadcrumbs.html b/layouts/partials/breadcrumbs.html index 742254a..7e8257b 100644 --- a/layouts/partials/breadcrumbs.html +++ b/layouts/partials/breadcrumbs.html @@ -1,6 +1,6 @@ {{- if (.Param "ShowBreadCrumbs") -}}