From 09fac88cb534d3018517fa636da0d167da18ade4 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sun, 20 Jun 2021 16:43:33 +0200 Subject: [PATCH] fix: set scratch inside define block --- layouts/post/single.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/layouts/post/single.html b/layouts/post/single.html index dffd479..30240a9 100644 --- a/layouts/post/single.html +++ b/layouts/post/single.html @@ -1,5 +1,7 @@ -{{ .Scratch.Set "hasTOC" (ge (len .TableOfContents) 100) }} -{{ define "body-class" }}article-page keep-sidebar{{ if .Scratch.Get "hasTOC" }} has-toc{{ end }}{{ end }} +{{ define "body-class" }} + {{- .Scratch.Set "hasTOC" (ge (len .TableOfContents) 100) -}} + article-page keep-sidebar{{ if (.Scratch.Get "hasTOC") }} has-toc{{ end }} +{{ end }} {{ define "container-class" }}extended{{ end }} {{ define "main" }} {{ partial "article/article.html" . }} @@ -16,7 +18,7 @@ {{ end }} {{ define "left-sidebar" }} - {{ if .Scratch.Get "hasTOC" }} + {{ if (.Scratch.Get "hasTOC") }}
{{ (resources.Get "icons/back.svg").Content | safeHTML }} @@ -29,7 +31,7 @@ {{ end }} {{ define "right-sidebar" }} - {{ if .Scratch.Get "hasTOC" }} + {{ if (.Scratch.Get "hasTOC") }}