Merge pull request #141 from aormsby/PR-toc

Add basic Table of Contents for posts
This commit is contained in:
Radek Kozieł 2020-05-27 08:26:11 +02:00 committed by GitHub
commit ecf77d7031
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -96,6 +96,10 @@ paginate = 5
# Show reading time in minutes for posts # Show reading time in minutes for posts
showReadingTime = false showReadingTime = false
# Show table of contents at the top of your posts (defaults to false)
# Alternatively, add this param to post front matter for specific posts
toc = true
[languages] [languages]
[languages.en] [languages.en]
title = "Hello Friend" title = "Hello Friend"

View file

@ -40,6 +40,10 @@
{{ end }} {{ end }}
<div class="post-content"> <div class="post-content">
{{ if or .Params.Toc $.Site.Params.Toc }}
<h2>Table of Contents</h2>
<aside class="table-of-contents">{{ .TableOfContents }}</aside>
{{ end }}
{{ .Content }} {{ .Content }}
</div> </div>
{{ if eq .Type $.Site.Params.contentTypeName }} {{ if eq .Type $.Site.Params.contentTypeName }}