cupper-hugo-theme/layouts/partials/toc.html
lucasradaelli 8984ca9d6a
Custom css and localization support (#28)
* Adds i18n support for theme

* Adds a way for sites to have custom css.

This change adds a param to the theme (called customCss), which allows sites to
provide extra css under static/, so that they don't need to copy the theme's css
whole file.

If no custom css is in the params, this change is NOP.
2020-06-01 13:47:51 -05:00

20 lines
580 B
HTML

{{ $headings := findRE "<h2.*?>(.|\n])+?</h2>" .Content }}
{{ if ge (len $headings) 2 }}
<nav class="toc" aria-labelledby="toc-heading">
<h2 id="toc-heading">{{ T "table_of_contents" }}</h2>
<ol>
{{ range $headings }}
<li>
{{ $id := findRE "id=\".*\"" . }}
{{ $id = index $id 0 }}
{{ $id = strings.TrimPrefix "id=\"" $id }}
{{ $id = strings.TrimSuffix "\"" $id }}
<a href="#{{ $id }}">
{{ . | htmlUnescape | plainify }}
</a>
</li>
{{ end }}
</ol>
</nav>
{{ end }}