jefklakscodex/themes/jefklak-creative-portfolio/layouts/partials/taglist.html

34 lines
1.3 KiB
HTML

<!-- https://discourse.gohugo.io/t/lists-of-content-divided-by-posts-first-letter/8534/2 - create a list with all uppercase letters -->
{{ $letters := split "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "" }}
<!-- range all pages sorted by their title -->
{{ range $.Site.Pages.ByTitle }}
<!-- get the first character of each title. Assumes that the title is never empty! -->
{{ $firstChar := substr .Title 0 1 | upper }}
<!-- in case $firstChar is a letter -->
{{ if $firstChar | in $letters }}
<!-- get the current letter -->
{{ $curLetter := $.Scratch.Get "curLetter" }}
<!-- if $curLetter isn't set or the letter has changed -->
{{ if ne $firstChar $curLetter }}
<!-- update the current letter and print it -->
</ul>
<hr style="clear: both;"/>
{{ $.Scratch.Set "curLetter" $firstChar }}
<h5 style="float: left; color: grey;">
<svg class='icon icon-inline'>
<use xlink:href='#tag'></use>
</svg>
{{ $firstChar }}
</h5>
<ul style="text-align: left; float: left; margin-left: 20px; list-style-type: none; border-left: #eee 1px solid;">
{{ end }}
<li>
<a href="{{ .RelPermalink }}"><small>{{ .Title }}</small></a>
</li>
{{ end }}
{{ end }}
</ul>