hugo-theme-stack/layouts/post/single.html
2021-06-20 16:30:13 +02:00

46 lines
1.5 KiB
HTML

{{ .Scratch.Set "hasTOC" (ge (len .TableOfContents) 100) }}
{{ define "body-class" }}article-page keep-sidebar{{ if .Scratch.Get "hasTOC" }} has-toc{{ end }}{{ end }}
{{ define "container-class" }}extended{{ end }}
{{ define "main" }}
{{ partial "article/article.html" . }}
{{ partial "article/components/related-contents" . }}
{{ if or (not (isset .Params "comments")) (eq .Params.comments "true")}}
{{ partial "comments/include" . }}
{{ end }}
{{ partialCached "footer/footer" . }}
{{ partialCached "article/components/photoswipe" . }}
{{ end }}
{{ define "left-sidebar" }}
{{ if .Scratch.Get "hasTOC" }}
<div id="article-toolbar">
<a href="{{ .Site.BaseURL }}" class="back-home">
{{ (resources.Get "icons/back.svg").Content | safeHTML }}
<span>Back</span>
</a>
</div>
{{ else }}
{{ partial "sidebar/left.html" . }}
{{ end }}
{{ end }}
{{ define "right-sidebar" }}
{{ if .Scratch.Get "hasTOC" }}
<aside class="sidebar right-sidebar sticky">
<section class="widget archives">
<div class="widget-icon">
{{ partial "helper/icon" "hash" }}
</div>
<h2 class="widget-title section-title">Table of contents</h2>
<div class="widget--toc">
{{ .TableOfContents }}
</div>
</section>
</aside>
{{ end }}
{{ end }}