ref: cc15864744210497325b69d8c3b4130c9c5156ac
parent: b7a672fd22794ea7c32a958739c6b12aba5dadf8
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Wed Mar 1 07:30:41 EST 2017
hugolib: Only return RSSLink when RSS is available Fixes #1302
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -6,9 +6,9 @@
"strings"
"testing"
+ "html/template"
"os"
"path/filepath"
- "text/template"
//"github.com/fortytw2/leaktest"
"github.com/fsnotify/fsnotify"
@@ -369,6 +369,9 @@
require.Equal(t, "Home", enSite.Menus["main"].ByName()[0].Name)
require.Equal(t, "Heim", nnSite.Menus["main"].ByName()[0].Name)
+
+ // Issue #1302
+ require.Equal(t, template.URL(""), enSite.RegularPages[0].RSSLink)
// Issue #3108
next := enSite.RegularPages[0].Next
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -186,7 +186,7 @@
Sitemap Sitemap
- RSSLink template.HTML
+ RSSLink template.URL
URLPath
permalink *url.URL
@@ -1670,7 +1670,7 @@
return hugoInfo
}
-func (p *Page) RSSlink() template.HTML {
+func (p *Page) RSSlink() template.URL {
// TODO(bep) we cannot have two of these
// Remove in Hugo 0.20
helpers.Deprecated(".Page", "Use RSSlink", "RSSLink", true)
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -2087,7 +2087,9 @@
func (s *Site) setPageURLs(p *Page, in string) {
p.URLPath.URL = s.PathSpec.URLizeAndPrep(in)
p.URLPath.Permalink = s.Info.permalink(p.URLPath.URL)
- p.RSSLink = template.HTML(s.Info.permalink(in + ".xml"))
+ if p.Kind != KindPage && p.Kind != KindTaxonomyTerm {
+ p.RSSLink = template.URL(s.Info.permalink(in + ".xml"))
+ }
}
func (s *Site) newTaxonomyPage(plural, key string) *Page {
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -15,6 +15,7 @@
import (
"fmt"
+ "html/template"
"path/filepath"
"reflect"
"testing"
@@ -124,6 +125,10 @@
th.assertFileContent("public/others/index.html", "Terms List", "Others")
s := h.Sites[0]
+
+ // Issue #1302
+ term := s.getPage(KindTaxonomyTerm, "others")
+ require.Equal(t, template.URL(""), term.RSSLink)
// Issue #3070 preserveTaxonomyNames
if preserveTaxonomyNames {
--
⑨