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

Choose number of recent articles to show #411

Merged
merged 4 commits into from
Jan 10, 2023
Merged
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 config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enableCodeCopy = false
[homepage]
layout = "page" # valid options: page, profile, custom
showRecent = false
recentLimit = 5

[article]
showDate = true
Expand Down
1 change: 1 addition & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mainSections = ["samples"]
[homepage]
layout = "custom" # valid options: page, profile, custom
showRecent = true
recentLimit = 5

[article]
showDate = true
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Many of the article defaults here can be overridden on a per article basis by sp
|`footer.showScrollToTop`|`true`|When set to `true` the scroll to top arrow is displayed.|
|`homepage.layout`|`"page"`|The layout of the homepage. Valid values are `page`, `profile` or `custom`. When set to `custom`, you must provide your own layout by creating a `/layouts/partials/home/custom.html` file. Refer to the [Homepage Layout]({{< ref "homepage-layout" >}}) section for more details.|
|`homepage.showRecent`|`false`|Whether or not to display the recent articles list on the homepage.|
|`homepage.recentLimit`|`5`|The maximum number of recent articles to display when `homepage.showRecent` is `true`.|
|`article.showDate`|`true`|Whether or not article dates are displayed.|
|`article.showDateUpdated`|`false`|Whether or not the dates articles were updated are displayed.|
|`article.showAuthor`|`true`|Whether or not the author box is displayed in the article footer.|
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/recent-articles.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ if .Site.Params.homepage.showRecent | default false }}
<h2 class="mt-8 text-2xl font-extrabold">{{ i18n "shortcode.recent_articles" | emojify }}</h2>
{{ range first 5 (.Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) 5).Pages }}
{{ range first .Site.Params.homepage.recentLimit (.Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) .Site.Params.homepage.recentLimit).Pages }}
{{ partial "article-link.html" . }}
{{ end }}
{{ end }}