Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Add TOC to pages #126
Browse files Browse the repository at this point in the history
  • Loading branch information
trmendes authored and victor-pogor committed Mar 29, 2021
1 parent 6245177 commit cc65483
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

{{- define "content" -}}
{{- $params := .Scratch.Get "params" -}}

{{- $toc := $params.toc -}}
{{- if eq $toc true -}}
{{- $toc = .Site.Params.page.toc | default dict -}}
{{- else if eq $toc false -}}
{{- $toc = dict "enable" false -}}
{{- end -}}

{{- /* Auto TOC */ -}}
{{- if ne $toc.enable false -}}
<div class="toc" id="toc-auto">
<h2 class="toc-title">{{ T "contents" }}</h2>
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
</div>
{{- end -}}

<div class="page single special">
{{- /* Title */ -}}
<h1 class="single-title animated pulse faster">
Expand All @@ -13,6 +29,19 @@ <h1 class="single-title animated pulse faster">
<h2 class="single-subtitle">{{ . }}</h2>
{{- end -}}

{{- /* Static TOC */ -}}
{{- if ne $toc.enable false -}}
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ end }}">
<div class="details-summary toc-title">
<span>{{ T "contents" }}</span>
<span><i class="details-icon fas fa-angle-right"></i></span>
</div>
<div class="details-content toc-content" id="toc-content-static">
{{- dict "Content" .TableOfContents "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
</div>
</div>
{{- end -}}

{{- /* Content */ -}}
<div class="content" id="content">
{{- dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
Expand Down

0 comments on commit cc65483

Please sign in to comment.