summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-01 12:30:41 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-01 12:30:41 +0100
commitcc15864744210497325b69d8c3b4130c9c5156ac (patch)
treef7cf07369d80a29e8792a804c100f702e1146e4d /hugolib
parentb7a672fd22794ea7c32a958739c6b12aba5dadf8 (diff)
hugolib: Only return RSSLink when RSS is available
Fixes #1302
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/hugo_sites_build_test.go5
-rw-r--r--hugolib/page.go4
-rw-r--r--hugolib/site.go4
-rw-r--r--hugolib/taxonomy_test.go5
4 files changed, 14 insertions, 4 deletions
diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go
index e917d9f51..5772c7478 100644
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -6,9 +6,9 @@ import (
"strings"
"testing"
+ "html/template"
"os"
"path/filepath"
- "text/template"
//"github.com/fortytw2/leaktest"
"github.com/fsnotify/fsnotify"
@@ -370,6 +370,9 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
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
require.NotNil(t, next)
diff --git a/hugolib/page.go b/hugolib/page.go
index 455efd782..68e839f9a 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -186,7 +186,7 @@ type Page struct {
Sitemap Sitemap
- RSSLink template.HTML
+ RSSLink template.URL
URLPath
permalink *url.URL
@@ -1670,7 +1670,7 @@ func (p *Page) Hugo() *HugoInfo {
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)
diff --git a/hugolib/site.go b/hugolib/site.go
index 917080c10..e5b30a38d 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -2087,7 +2087,9 @@ func (s *Site) newHomePage() *Page {
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 {
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index f23693403..3c6dc2707 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -15,6 +15,7 @@ package hugolib
import (
"fmt"
+ "html/template"
"path/filepath"
"reflect"
"testing"
@@ -125,6 +126,10 @@ others:
s := h.Sites[0]
+ // Issue #1302
+ term := s.getPage(KindTaxonomyTerm, "others")
+ require.Equal(t, template.URL(""), term.RSSLink)
+
// Issue #3070 preserveTaxonomyNames
if preserveTaxonomyNames {
helloWorld := s.getPage(KindTaxonomy, "others", "Hello Hugo world")