mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 22:21:07 +03:00
hugolib: Make RSS item limit configurable
Add a new rssLimit site configuration option with default of 15. Prior to this fix, you could create your own RSS feed to override the default limit of 15, but we still had a hardcoded limit of 50 items set in `hugolib.renderRSS()`. With this option in place, the `range first 15 .Data.Pages` logic is no longer hardcoded into the embedded RSS template. Because the size of the slice passed to the template is now limited to rssLimit instead of 50, this commit is a breaking change for sites with a custom RSS template that expects more than 15 items. Fixes #3035
This commit is contained in:
parent
ade207635e
commit
10c13f5d79
5 changed files with 17 additions and 4 deletions
|
@ -152,9 +152,9 @@ func (s *Site) renderRSS(p *Page) error {
|
|||
rssPage.Date = zeroDate
|
||||
}
|
||||
|
||||
high := 50
|
||||
if len(rssPage.Pages) > high {
|
||||
rssPage.Pages = rssPage.Pages[:high]
|
||||
limit := s.Cfg.GetInt("rssLimit")
|
||||
if len(rssPage.Pages) > limit {
|
||||
rssPage.Pages = rssPage.Pages[:limit]
|
||||
rssPage.Data["Pages"] = rssPage.Pages
|
||||
}
|
||||
rssURI := s.Language.GetString("rssURI")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue