Personal_Website/layouts/partials/generic-list.html

31 lines
1.2 KiB
HTML

{{ $labelSingular := index $ "labelSingular" }}
{{ $labelPlural := or (index $ "labelPlural") (print $labelSingular "s") }}
{{ $maximumListSize := or (index $ "maximumListSize") 3 }}
{{ $pageType := index $ "pageType"}}
{{ $viewAllHref := or (index $ "viewAllHref") (print "/" $labelPlural) }}
<section class="list">
<div class="header">
<h3>Latest {{ $labelPlural | title }}</h3>
{{ if index $ "showViewAllButton" }}
<div class="view-all">
<a href="{{ $viewAllHref }}">All {{ $labelPlural }}</a>
</div>
{{ end }}
</div>
<div class="list-items-container">
<ul class="list-items">
{{ range ( first $maximumListSize (where site.RegularPages "Type" $pageType).ByDate.Reverse ) }}
<li class="list-item" data-href="{{ .Permalink }}">
<img class="list-item-image" src="//via.placeholder.com/128" alt="{{ index $ "labelSingular" }} Topic">
<div class="list-item-text">
<h4 class="list-item-title">{{ .Title }}</h4>
<span class="list-item-date">{{ .Date.Format "January 2, 2006" }}</span>
</div>
</li>
{{ end }}
</ul>
</div>
</section>