]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Re-add site.RSSLink (and deprecate it)
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 14 Jun 2023 10:04:32 +0000 (12:04 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 14 Jun 2023 10:18:11 +0000 (12:18 +0200)
Fixes #11110

hugolib/site_new.go
hugolib/site_output_test.go
resources/page/site.go

index 4b3a28bddf1db8250453f0a9115bb957e30855ed..911414121e0ab55eaaef0b4b98fd37e828d56df9 100644 (file)
@@ -29,6 +29,7 @@ import (
        "github.com/gohugoio/hugo/config"
        "github.com/gohugoio/hugo/config/allconfig"
        "github.com/gohugoio/hugo/deps"
+       "github.com/gohugoio/hugo/helpers"
        "github.com/gohugoio/hugo/identity"
        "github.com/gohugoio/hugo/langs"
        "github.com/gohugoio/hugo/langs/i18n"
@@ -345,12 +346,10 @@ func (s *Site) Copyright() string {
        return s.conf.Copyright
 }
 
-func (s *Site) RSSLink() string {
-       rssOutputFormat, found := s.conf.C.KindOutputFormats[page.KindHome].GetByName("rss")
-       if !found {
-               return ""
-       }
-       return s.permalink(rssOutputFormat.BaseFilename())
+func (s *Site) RSSLink() template.URL {
+       helpers.Deprecated("Site.RSSLink", "Use the Output Format's Permalink method instead, e.g. .OutputFormats.Get \"RSS\".Permalink", false)
+       rssOutputFormat := s.home.OutputFormats().Get("rss")
+       return template.URL(rssOutputFormat.Permalink())
 }
 
 func (s *Site) Config() page.SiteConfig {
index c5cee7641deea848b84f1cf42c89e3ad5a173bf9..b598e23d61d8f9d3b46a2a381cdfe0f16f332ea9 100644 (file)
@@ -15,6 +15,7 @@ package hugolib
 
 import (
        "fmt"
+       "html/template"
        "strings"
        "testing"
 
@@ -248,7 +249,7 @@ baseName = "feed"
        s := h.Sites[0]
 
        // Issue #3450
-       c.Assert(s.RSSLink(), qt.Equals, "http://example.com/blog/feed.xml")
+       c.Assert(s.RSSLink(), qt.Equals, template.URL("http://example.com/blog/feed.xml"))
 }
 
 // Issue #3614
index ccc36a4eebb9a51061d4afc5cbc4f4524d4116ce..6a352ef866c3013406b885afec1170585e01392e 100644 (file)
@@ -137,6 +137,9 @@ type Site interface {
 
        // LanguagePrefix returns the language prefix for this site.
        LanguagePrefix() string
+
+       // Deprecated. Use site.Home.OutputFormats.Get "rss" instead.
+       RSSLink() template.URL
 }
 
 // Sites represents an ordered list of sites (languages).
@@ -300,6 +303,10 @@ func (s *siteWrapper) LanguagePrefix() string {
        return s.s.LanguagePrefix()
 }
 
+func (s *siteWrapper) RSSLink() template.URL {
+       return s.s.RSSLink()
+}
+
 type testSite struct {
        h hugo.HugoInfo
        l *langs.Language
@@ -444,6 +451,10 @@ func (s testSite) Param(key any) (any, error) {
        return nil, nil
 }
 
+func (s testSite) RSSLink() template.URL {
+       return ""
+}
+
 // NewDummyHugoSite creates a new minimal test site.
 func NewDummyHugoSite(conf config.AllProvider) Site {
        return testSite{