Fix content template

This commit is contained in:
ItsDrike 2022-05-14 23:11:39 +02:00
parent b444f03185
commit 7f84716ce8
No known key found for this signature in database
GPG key ID: B014E761034AF742

View file

@ -20,26 +20,27 @@
<div class="content mt-3"> <div class="content mt-3">
{{ if .TableOfContents }} {{ if .TableOfContents }}
<!-- Get the amount of headers using regex --> <!-- Get the amount of headers using regex -->
{{ $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content }} {{ $headers := findRE "<h[1-6] ?.*?>(.|\n)*?</h[1-6]>" .Content }}
<!-- We only need to show a table of contents if we have over 4 headers --> <!-- We only need to show a table of contents if we have over 4 headers -->
{{ if ge (len $headers) 4 }} {{ if ge (len $headers) 4 }}
<div class="float-lg-end ml-lg-3 mb-3 p-3"> <div class="float-lg-end ml-lg-3 mb-3 p-3">
{{ .TableOfContents }} {{ .TableOfContents }}
</div> </div>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ .Content }}
{{ .Content }}
<div id="sources"> <div id="sources">
{{ if .Params.Sources }} {{ if .Params.Sources }}
<h2>Sources</h2> <h2>Sources</h2>
<ul> <ul>
{{ range $i, $e := .Params.Sources }} {{ range $i, $e := .Params.Sources }}
<li>{{ markdownify $e }}</li> <li>{{ markdownify $e }}</li>
{{ end }}
</ul>
{{ end }} {{ end }}
</div> </ul>
{{ end }}
</div>
</div> </div>
{{ end }} {{ end }}