add Latest Posts to index.html

This commit is contained in:
Thomas T 2023-12-29 21:54:04 -05:00 committed by GitHub
parent 0ca5b0e5e0
commit def2058360
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,27 @@
{{ define "main" }}
<h2>{{ i18n "latest-posts" }}</h2>
{{ $pages := first .Site.Params.latestPostsCount (where .Site.RegularPages "Section" "blog") }}
<ul class="blog-posts">
{{ range $pages }}
<li>
<span>
<i>
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
{{ .Date.Format (default "2006-01-02" .Site.Params.dateFormat) }}
</time>
</i>
</span>
{{ if .Params.link }}
<a href="{{ .Params.link }}" target="_blank">{{ .Title }} ↪</a>
{{ else }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}
</li>
{{ else }}
<li>
{{ i18n "no-posts" }}
</li>
{{ end }}
</ul>
{{ .Content }}
{{ end }}