summaryrefslogtreecommitdiffstats
path: root/layouts/partials/sidebar-toc.html
blob: a6ac8d38e5cf09c5b4e2bf8352f86ca8e810e280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{{/* Target for toggling the sidebar `.sidebar-checkbox` is for regular styles, `#sidebar-checkbox` for behavior. */}}
<input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox">

<!-- Toggleable sidebar -->
<aside class="sidebar" id="sidebar">
    <div class="sidebar-item">
        <p>{{ .Title }}</p>
    </div>

    {{ $toc := .Page.TableOfContents }}
    {{ $home := printf `<a class="sidebar-nav-item" href="%s">%s</a>` site.Home.RelPermalink (i18n "home") | safeHTML }}
    {{ $annotation := "" }}

    {{ if ne .Params.annotations false }}
    {{ $annotation = (partial "hypothesis.html" .) }}
    {{ end }}

    {{ $toc = $toc | replaceRE `id="TableOfContents"` `class="sidebar-nav"` | safeHTML }}
    {{ $toc = $toc | replaceRE "(<[/]?ul>|<[/]?ol>|<[/]?li>)" "" | safeHTML }}
    {{ $toc = $toc | replaceRE `<a href="(.*)">(.*)</a>` `<a class="sidebar-nav-item sidebar-nav-item-toc" href="$1">$2</a>` | safeHTML }}

    {{ if ne .Params.annotations false }}
    {{ $toc = $toc | replaceRE `<nav class="sidebar-nav">` (printf `<nav class="sidebar-nav">%s` $annotation) | safeHTML }}
    {{ end }}

    {{ $toc = $toc | replaceRE `<nav class="sidebar-nav">` (printf `<nav class="sidebar-nav">%s` $home) | safeHTML }}

    {{ $toc }}

    {{ partial "footer" . }}
</aside>