summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/content/overview/configuration.md2
-rw-r--r--hugolib/config.go1
-rw-r--r--hugolib/rss_test.go10
-rw-r--r--hugolib/site_render.go6
-rw-r--r--tpl/tplimpl/template_embedded.go2
5 files changed, 17 insertions, 4 deletions
diff --git a/docs/content/overview/configuration.md b/docs/content/overview/configuration.md
index 21b424ad6..b2ed06804 100644
--- a/docs/content/overview/configuration.md
+++ b/docs/content/overview/configuration.md
@@ -171,6 +171,8 @@ along with their current, default values:
pygmentsStyle: "monokai"
# true: use pygments-css or false: color-codes directly
pygmentsUseClasses: false
+ # maximum number of items in the RSS feed
+ rssLimit: 15
# default sitemap configuration map
sitemap:
# filesystem path to read files relative from
diff --git a/hugolib/config.go b/hugolib/config.go
index 552b19dac..2d0cfe8ee 100644
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -102,6 +102,7 @@ func loadDefaultSettingsFor(v *viper.Viper) {
v.SetDefault("paginatePath", "page")
v.SetDefault("blackfriday", c.NewBlackfriday())
v.SetDefault("rSSUri", "index.xml")
+ v.SetDefault("rssLimit", 15)
v.SetDefault("sectionPagesMenu", "")
v.SetDefault("disablePathToLower", false)
v.SetDefault("hasCJKLanguage", false)
diff --git a/hugolib/rss_test.go b/hugolib/rss_test.go
index 0a7f84a42..0d14bf5d6 100644
--- a/hugolib/rss_test.go
+++ b/hugolib/rss_test.go
@@ -15,6 +15,7 @@ package hugolib
import (
"path/filepath"
+ "strings"
"testing"
"github.com/spf13/hugo/deps"
@@ -27,11 +28,14 @@ func TestRSSOutput(t *testing.T) {
th = testHelper{cfg}
)
+ rssLimit := len(weightedSources) - 1
+
rssURI := "customrss.xml"
cfg.Set("baseURL", "http://auth/bub/")
cfg.Set("rssURI", rssURI)
cfg.Set("title", "RSSTest")
+ cfg.Set("rssLimit", rssLimit)
for _, src := range weightedSources {
writeSource(t, fs, filepath.Join("content", "sect", src.Name), string(src.Content))
@@ -46,4 +50,10 @@ func TestRSSOutput(t *testing.T) {
// Taxonomy RSS
th.assertFileContent(t, fs, filepath.Join("public", "categories", "hugo", rssURI), true, "<?xml", "rss version", "Hugo on RSSTest")
+ // RSS Item Limit
+ content := readDestination(t, fs, filepath.Join("public", rssURI))
+ c := strings.Count(content, "<item>")
+ if c != rssLimit {
+ t.Errorf("incorrect RSS item count: expected %d, got %d", rssLimit, c)
+ }
}
diff --git a/hugolib/site_render.go b/hugolib/site_render.go
index fa398aa04..23b5a11b4 100644
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -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")
diff --git a/tpl/tplimpl/template_embedded.go b/tpl/tplimpl/template_embedded.go
index abe5937bd..f0b32bdd6 100644
--- a/tpl/tplimpl/template_embedded.go
+++ b/tpl/tplimpl/template_embedded.go
@@ -77,7 +77,7 @@ func (t *GoHTMLTemplate) EmbedTemplates() {
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<atom:link href="{{.Permalink}}" rel="self" type="application/rss+xml" />
- {{ range first 15 .Data.Pages }}
+ {{ range .Data.Pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>