Skip to content

Commit

Permalink
fix: recent posts on home page is not correctly filtered (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
boh717 authored Apr 14, 2023
1 parent fd3d59c commit 4afdfcb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ enableEmoji = true
sitename = "Awesome hugo blog"
defaultColor = "dark" # set default color mode: dark or light
description = "Minimal Hugo blog theme with light and dark mode support"
mainSections = ['posts']

[params.author]
avatar = "avatar.jpg" # put the file in assets folder; also ensure that image has same height and width
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<main aria-label="Content">
<h3 class="posts-item-note" aria-label="Recent Posts">Recent Posts</h3>
{{/* Show last 5 posts in reverse date order */}}
{{ $posts := .Site.RegularPages.ByDate.Reverse }}
{{ $pagesToShow := where .Site.RegularPages "Type" "in" site.Params.mainSections }}
{{ $posts := $pagesToShow.ByDate.Reverse }}
{{ range first 5 $posts }}
{{ partial "postCard" . }}
{{ end }}
Expand Down

0 comments on commit 4afdfcb

Please sign in to comment.