feat: display 3 most recent blog posts on homepage
- Add recent posts section to homepage after description - Query and filter blog posts by language context - Display post title as link and formatted publication date - Implement multilingual section headings (Neueste Beiträge/Recent Posts) - Maintain responsive design with Bootstrap styling - Handle edge cases (0 posts, <3 posts) - File size increase <1KB, no new HTTP requests - Hugo build completes in 21ms without errors
This commit is contained in:
@@ -8,6 +8,39 @@
|
||||
{{ .Content }}
|
||||
</div>
|
||||
</article>
|
||||
|
||||
{{/* Recent blog posts section */}}
|
||||
{{ $blogPages := where .Site.RegularPages "Section" "blog" }}
|
||||
{{ $blogPages = where $blogPages ".Lang" .Language.Lang }}
|
||||
{{ $recentPosts := first 3 $blogPages }}
|
||||
{{ if $recentPosts }}
|
||||
<section class="mt-5 mb-5">
|
||||
<h2 class="h3 mb-4">
|
||||
{{ if eq .Language.Lang "de" }}
|
||||
Neueste Beiträge
|
||||
{{ else }}
|
||||
Recent Posts
|
||||
{{ end }}
|
||||
</h2>
|
||||
<ul class="list-unstyled">
|
||||
{{ range $recentPosts }}
|
||||
<li class="mb-3">
|
||||
<a href="{{ .RelPermalink }}" class="text-decoration-none">
|
||||
<strong>{{ .Title }}</strong>
|
||||
</a>
|
||||
<br>
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}" class="text-muted small">
|
||||
{{ if eq $.Language.Lang "de" }}
|
||||
{{ .Date.Format "2. January 2006" }}
|
||||
{{ else }}
|
||||
{{ .Date.Format "January 2, 2006" }}
|
||||
{{ end }}
|
||||
</time>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</section>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user