summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-24 16:54:37 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-27 15:43:56 +0200
commit5761b93c96e89a1e269156c179841301e5808fad (patch)
treee587df59eadc45a2ab86c86c65a2956d1812b961 /hugolib
parent87188496fbb68c39567ec3ee3a55a9305a13e48b (diff)
hugolib, output: Fix RSSLink vs output formats
And remove the now superflous setPageURLs method.
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/hugo_sites_build_test.go2
-rw-r--r--hugolib/page.go12
-rw-r--r--hugolib/page_test.go3
-rw-r--r--hugolib/site.go15
-rw-r--r--hugolib/site_render.go2
5 files changed, 11 insertions, 23 deletions
diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go
index e5e36bdcd..5f3ef7a70 100644
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -372,7 +372,7 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
require.Equal(t, "Heim", nnSite.Menus["main"].ByName()[0].Name)
// Issue #1302
- require.Equal(t, template.URL(""), enSite.RegularPages[0].RSSLink)
+ require.Equal(t, template.URL(""), enSite.RegularPages[0].RSSLink())
// Issue #3108
next := enSite.RegularPages[0].Next
diff --git a/hugolib/page.go b/hugolib/page.go
index dba3942de..36c89d958 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -184,8 +184,6 @@ type Page struct {
Sitemap Sitemap
- RSSLink template.URL
-
URLPath
permalink string
relPermalink string
@@ -210,6 +208,14 @@ type Page struct {
targetPathDescriptorPrototype *targetPathDescriptor
}
+func (p *Page) RSSLink() template.URL {
+ f, found := p.outputFormats.GetByName(output.RSSType.Name)
+ if !found {
+ return ""
+ }
+ return template.URL(newOutputFormat(p, f).Permalink())
+}
+
func (p *Page) createLayoutDescriptor() output.LayoutDescriptor {
var section string
@@ -1541,7 +1547,7 @@ func (p *Page) RSSlink() template.URL {
// TODO(bep) we cannot have two of these
// Remove in Hugo 0.20
helpers.Deprecated(".Page", "RSSlink", "Use RSSLink", true)
- return p.RSSLink
+ return p.RSSLink()
}
func (p *Page) Ref(ref string) (string, error) {
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index d23918603..790a69b38 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -1346,7 +1346,6 @@ func TestIndexPageSimpleMethods(t *testing.T) {
}{
{func(n *Page) bool { return n.IsNode() }},
{func(n *Page) bool { return !n.IsPage() }},
- {func(n *Page) bool { return n.RSSLink == "rssLink" }},
{func(n *Page) bool { return n.Scratch() != nil }},
{func(n *Page) bool { return n.Hugo() != nil }},
{func(n *Page) bool { return n.Now().Unix() == time.Now().Unix() }},
@@ -1354,8 +1353,6 @@ func TestIndexPageSimpleMethods(t *testing.T) {
n := s.newHomePage()
- n.RSSLink = "rssLink"
-
if !this.assertFunc(n) {
t.Errorf("[%d] Node method error", i)
}
diff --git a/hugolib/site.go b/hugolib/site.go
index 536bf738b..fa37f41d1 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -20,7 +20,6 @@ import (
"io"
"net/url"
"os"
- "path"
"path/filepath"
"strconv"
"strings"
@@ -2054,19 +2053,9 @@ func (s *Site) newHomePage() *Page {
pages := Pages{}
p.Data["Pages"] = pages
p.Pages = pages
- s.setPageURLs(p, "/")
return p
}
-// TODO(bep) output
-func (s *Site) setPageURLs(p *Page, in string) {
- p.URLPath.URL = s.PathSpec.URLizeAndPrep(in)
- p.URLPath.Permalink = s.permalink(p.URLPath.URL)
- if p.Kind != KindPage {
- p.RSSLink = template.URL(s.permalink(p.URLPath.URL + ".xml"))
- }
-}
-
func (s *Site) newTaxonomyPage(plural, key string) *Page {
p := s.newNodePage(KindTaxonomy, plural, key)
@@ -2081,8 +2070,6 @@ func (s *Site) newTaxonomyPage(plural, key string) *Page {
p.Title = strings.Replace(strings.Title(key), "-", " ", -1)
}
- s.setPageURLs(p, path.Join(plural, key))
-
return p
}
@@ -2100,13 +2087,11 @@ func (s *Site) newSectionPage(name string, section WeightedPages) *Page {
} else {
p.Title = sectionName
}
- s.setPageURLs(p, name)
return p
}
func (s *Site) newTaxonomyTermsPage(plural string) *Page {
p := s.newNodePage(KindTaxonomyTerm, plural)
p.Title = strings.Title(plural)
- s.setPageURLs(p, plural)
return p
}
diff --git a/hugolib/site_render.go b/hugolib/site_render.go
index d16adcfaf..5290f0179 100644
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -218,7 +218,7 @@ func (s *Site) render404() error {
p.Title = "404 Page not found"
p.Data["Pages"] = s.Pages
p.Pages = s.Pages
- s.setPageURLs(p, "404.html")
+ p.URLPath.URL = "404.html"
nfLayouts := []string{"404.html"}