single.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {{ define "body-class" }}
  2. article-page
  3. {{/*
  4. Enable the right sidebar if
  5. - Widget different from 'TOC' is enabled
  6. - TOC is enabled and not empty
  7. */}}
  8. {{- $HasWidgetNotTOC := false -}}
  9. {{- $TOCWidgetEnabled := false -}}
  10. {{- range .Site.Params.widgets.page -}}
  11. {{- if ne .type "toc" -}}
  12. {{ $HasWidgetNotTOC = true -}}
  13. {{- else -}}
  14. {{ $TOCWidgetEnabled = true -}}
  15. {{- end -}}
  16. {{- end -}}
  17. {{- $TOCManuallyDisabled := eq .Params.toc false -}}
  18. {{- $TOCEnabled := and (not $TOCManuallyDisabled) $TOCWidgetEnabled -}}
  19. {{- $hasTOC := ge (len .TableOfContents) 100 -}}
  20. {{- .Scratch.Set "TOCEnabled" (and $TOCEnabled $hasTOC) -}}
  21. {{- .Scratch.Set "hasWidget" (or $HasWidgetNotTOC (and $TOCEnabled $hasTOC)) -}}
  22. {{ end }}
  23. {{ define "main" }}
  24. {{ partial "article/article.html" . }}
  25. {{ if .Params.links }}
  26. {{ partial "article/components/links" . }}
  27. {{ end }}
  28. {{ partial "article/components/related-contents" . }}
  29. {{ if not (eq .Params.comments false) }}
  30. {{ partial "comments/include" . }}
  31. {{ end }}
  32. {{ partialCached "footer/footer" . }}
  33. {{ partialCached "article/components/photoswipe" . }}
  34. {{ end }}
  35. {{ define "right-sidebar" }}
  36. {{ if .Scratch.Get "hasWidget" }}{{ partial "sidebar/right.html" (dict "Context" . "Scope" "page") }}{{ end}}
  37. {{ end }}