Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to disable category post listings on the home page #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ copyright = "© Copyright Year, Your Name"
home_image = "/images/avatar.png" # Path to header image starting from the static directory
recent_posts = 5 # Max amount of recent posts to show
mainSections = ["posts", "post", "blog"] # Main sections to include in recent posts
category_list = true # Include category posts on the home page
[params.style] # CSS style overrides
backgroundColor = "#f8f9fa"
fontColor = "#212529"
Expand Down
36 changes: 19 additions & 17 deletions layouts/partials/category-posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,40 @@
<div class="col-12">
{{ $recent := 7 }}
{{ if isset .Site.Params "recent_posts" }}
{{ $recent = .Site.Params.recent_posts }}
{{ $recent = .Site.Params.recent_posts }}
{{ end }}
{{ if gt $recent 0 }}
<div class="pb-3">
<h5><span class="badge category">Recent</span></h5>
<ul class="list-unstyled">
{{ range first $recent (where .Site.RegularPages "Type" "in" site.Params.mainSections) }}
<li>
{{ .Date.Format "Jan 2 2006" }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
<li>
{{ .Date.Format "Jan 2 2006" }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
</div>
{{ end }}

{{ if or (not (isset .Site.Params "category_list")) (.Site.Params.category_list) }}
{{ range $key, $taxonomy := .Site.Taxonomies.categories.Alphabetical }}
<div class="pb-3">
<h5>
<div class="pb-3">
<h5>
<span class="badge category text-capitalize">
{{ .Name | humanize }}
</span>
</h5>
<ul class="list-unstyled">
{{ range $taxonomy.Pages }}
<li>
{{ .Date.Format "Jan 2 2006" }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
</div>
</h5>
<ul class="list-unstyled">
{{ range $taxonomy.Pages }}
<li>
{{ .Date.Format "Jan 2 2006" }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ end }}
</div>
</div>
Expand Down