Create a new table_of_contents partial that includes an auto-generated table of contents if the word count is over 400 and the "toc" page variable has been set true.
33 lines
532 B
HTML
33 lines
532 B
HTML
{{ define "header" }}
|
|
{{ partial "header.html" . }}
|
|
{{ end }}
|
|
|
|
{{ define "main" }}
|
|
<header class="page">
|
|
<h1>{{ .Title }}</h1>
|
|
</header>
|
|
|
|
{{ partial "table_of_contents.html" . }}
|
|
|
|
{{- $hasContent := false -}}
|
|
{{ with .Content }}
|
|
{{- $hasContent = true -}}
|
|
<section>
|
|
{{ . }}
|
|
</section>
|
|
{{ end }}
|
|
|
|
{{ if $hasContent }}
|
|
<h2>Posts</h2>
|
|
{{ end }}
|
|
|
|
<ul>
|
|
{{- range .Pages -}}
|
|
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
|
|
{{- end -}}
|
|
</ul>
|
|
{{ end }}
|
|
|
|
{{ define "footer" }}
|
|
{{ partial "footer.html" . }}
|
|
{{ end }}
|