add include_toc options in FrontMatter

This commit is contained in:
Terry Rod 2019-04-02 14:22:00 +08:00
parent 160b3d9400
commit 5427aefb1f
2 changed files with 15 additions and 11 deletions

View file

@ -1,3 +1,4 @@
{{ $include_toc := .Params.include_toc}}
<article>
<header>
<h1>{{ .Title }}</h1>
@ -10,15 +11,17 @@
</header>
{{ $tableOfContents := .TableOfContents }}
{{ with .Site.Params.toc }}
<div class="toc-wrapper">
<input type="checkbox" id="tocToggle">
<label for="tocToggle">Table of Content</label>
{{ if eq . "hugo" }}
{{ $tableOfContents }}
{{ else if eq . "tocbot"}}
<div class="toc" id="TableOfContents"></div>
{{ end }}
</div>
{{ if ne $include_toc false }}
<div class="toc-wrapper">
<input type="checkbox" id="tocToggle">
<label for="tocToggle">Table of Content</label>
{{ if eq . "hugo" }}
{{ $tableOfContents }}
{{ else if eq . "tocbot"}}
<div class="toc" id="TableOfContents"></div>
{{ end }}
</div>
{{ end }}
{{ end }}
<div class="post">
{{ .Content }}