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 435d2a1e..e400e2c5 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 6dfe7415..3d13f07a 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 2c86f7c4..feeb437d 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 0cc1ad9e..f4ff6eca 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) }}
- {{- $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 d5a9e66e..6fd26540 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 4582b126..8f2758fa 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 742254a3..7e8257b7 100644
--- a/layouts/partials/breadcrumbs.html
+++ b/layouts/partials/breadcrumbs.html
@@ -1,6 +1,6 @@
{{- if (.Param "ShowBreadCrumbs") -}}
- {{- $url := replace .Parent.Permalink (printf "%s" .Site.BaseURL) "" }}
+ {{- $url := replace .Parent.Permalink (printf "%s" site.BaseURL) "" }}
{{- $lang_url := strings.TrimPrefix (printf "%s/" .Lang) $url -}}
{{ i18n "home" | default "Home" }}
@@ -8,7 +8,7 @@
{{- range $index, $element := split $lang_url "/" }}
{{- $scratch.Add "path" (printf "%s/" $element )}}
- {{- $bc_pg := $.Site.GetPage ($scratch.Get "path") -}}
+ {{- $bc_pg := site.GetPage ($scratch.Get "path") -}}
{{- if (and ($bc_pg) (gt (len . ) 0))}}
{{- print " ยป " | safeHTML -}}
{{ $bc_pg.Name }}
diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html
index b4e7c786..5c5f2fbb 100644
--- a/layouts/partials/cover.html
+++ b/layouts/partials/cover.html
@@ -2,8 +2,8 @@
{{- if (and .Params.cover.image (not $.isHidden)) }}
{{- $alt := (.Params.cover.alt | default .Params.cover.caption | plainify) }}