diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 184cd56..9c7c917 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,4 +1,6 @@ -{{- partial "init.html" . -}} +{{- range $k, $v := (partialCached "init.html" .) -}} + {{- $.Scratch.Set $k $v -}} +{{- end -}} @@ -28,13 +30,13 @@ {{- block "main" . }}{{- end }} {{- if .IsPage }} - {{- partial "comments.html" . }} + {{- partialCached "comments.html" . }} {{- end }} diff --git a/layouts/partials/init.html b/layouts/partials/init.html index 446d64b..c572261 100644 --- a/layouts/partials/init.html +++ b/layouts/partials/init.html @@ -5,9 +5,14 @@ {{- errorf "Because that use SCSS framework in Hugo NexT, Please download Hugo extended version on offical site: https://github.com/gohugoio/hugo/releases" -}} {{- end }} -{{- .Scratch.Set "postsCount" (len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections)) -}} -{{- .Scratch.Set "catsCount" (len .Site.Taxonomies.categories) -}} -{{- .Scratch.Set "tagsCount" (len .Site.Taxonomies.tags) -}} +{{- $globalVars := newScratch -}} + +{{- $globalVars.Set "postsCount" (len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections)) -}} +{{- $globalVars.Set "catsCount" (len .Site.Taxonomies.categories) -}} +{{- $globalVars.Set "tagsCount" (len .Site.Taxonomies.tags) -}} + {{- $vendor := .Site.Params.vendors.plugins -}} {{- $router := index .Site.Data.resources.vendors $vendor -}} -{{- .Scratch.Set "router" $router -}} \ No newline at end of file +{{- $globalVars.Set "router" $router -}} + +{{- return $globalVars.Values -}}