Skip to content

Commit

Permalink
hugolib: Do not set RSS as Kind in RSS output
Browse files Browse the repository at this point in the history
Before Hugo this commit  we set the pseudo page kind RSS on the page when output to RSS. This had some unintended side effects, esp. when the only output format for that page  was RSS.

For the page kinds that can have multiple output formats, the Kind should be one of the standard home, page etc.

Fixes gohugoio#5138
  • Loading branch information
bep committed Sep 14, 2018
1 parent 75e5434 commit 555a561
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 18 additions & 0 deletions hugolib/rss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,21 @@ func TestRSSOutput(t *testing.T) {
t.Errorf("incorrect RSS item count: expected %d, got %d", rssLimit, c)
}
}

// Before Hugo 0.49 we set the pseudo page kind RSS on the page when output to RSS.
// This had some unintended side effects, esp. when the only output format for that page
// was RSS.
// For the page kinds that can have multiple output formats, the Kind should be one of the
// standard home, page etc.
// This test has this single purpose: Check that the Kind is that of the source page.
// See https://github.com/gohugoio/hugo/issues/5138
func TestRSSKind(t *testing.T) {
t.Parallel()

b := newTestSitesBuilder(t)
b.WithSimpleConfigFile().WithTemplatesAdded("index.rss.xml", `RSS Kind: {{ .Kind }}`)

b.Build(BuildCfg{})

b.AssertFileContent("public/index.xml", "RSS Kind: home")
}
2 changes: 0 additions & 2 deletions hugolib/site_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ func (s *Site) renderRSS(p *PageOutput) error {
return nil
}

p.Kind = kindRSS

limit := s.Cfg.GetInt("rssLimit")
if limit >= 0 && len(p.Pages) > limit {
p.Pages = p.Pages[:limit]
Expand Down

0 comments on commit 555a561

Please sign in to comment.