Skip to content

Commit

Permalink
Make site.BaseURL and $pager.URL a string
Browse files Browse the repository at this point in the history
Was template.URL.
  • Loading branch information
bep committed Oct 30, 2023
1 parent acf01bf commit b6a7568
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions hugolib/site_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ func (s *Site) Hugo() hugo.HugoInfo {
}

// Returns the BaseURL for this Site.
func (s *Site) BaseURL() template.URL {
return template.URL(s.conf.C.BaseURL.WithPath)
func (s *Site) BaseURL() string {
return s.conf.C.BaseURL.WithPath
}

// Returns the last modification date of the content.
Expand Down
5 changes: 2 additions & 3 deletions resources/page/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package page
import (
"errors"
"fmt"
"html/template"
"math"
"reflect"

Expand Down Expand Up @@ -71,8 +70,8 @@ func (p *Pager) PageNumber() int {
}

// URL returns the URL to the current page.
func (p *Pager) URL() template.HTML {
return template.HTML(p.paginationURLFactory(p.PageNumber()))
func (p *Pager) URL() string {
return p.paginationURLFactory(p.PageNumber())
}

// Pages returns the Pages on this page.
Expand Down
5 changes: 2 additions & 3 deletions resources/page/pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package page
import (
"context"
"fmt"
"html/template"
"testing"

qt "github.com/frankban/quicktest"
Expand Down Expand Up @@ -119,7 +118,7 @@ func doTestPages(t *testing.T, paginator *Paginator) {
c.Assert(paginator.TotalPages(), qt.Equals, 5)

first := paginatorPages[0]
c.Assert(first.URL(), qt.Equals, template.HTML("page/1/"))
c.Assert(first.URL(), qt.Equals, "page/1/")
c.Assert(first.First(), qt.Equals, first)
c.Assert(first.HasNext(), qt.Equals, true)
c.Assert(first.Next(), qt.Equals, paginatorPages[1])
Expand All @@ -134,7 +133,7 @@ func doTestPages(t *testing.T, paginator *Paginator) {
c.Assert(third.Prev(), qt.Equals, paginatorPages[1])

last := paginatorPages[4]
c.Assert(last.URL(), qt.Equals, template.HTML("page/5/"))
c.Assert(last.URL(), qt.Equals, "page/5/")
c.Assert(last.Last(), qt.Equals, last)
c.Assert(last.HasNext(), qt.Equals, false)
c.Assert(last.Next(), qt.IsNil)
Expand Down
8 changes: 5 additions & 3 deletions resources/page/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type Site interface {
Hugo() hugo.HugoInfo

// Returns the BaseURL for this Site.
BaseURL() template.URL
BaseURL() string

// Returns a taxonomy map.
Taxonomies() TaxonomyList
Expand Down Expand Up @@ -172,6 +172,7 @@ func (s *siteWrapper) Social() map[string]string {
func (s *siteWrapper) Author() map[string]interface{} {
return s.s.Author()
}

func (s *siteWrapper) Authors() AuthorList {
return AuthorList{}
}
Expand Down Expand Up @@ -250,7 +251,7 @@ func (s *siteWrapper) Hugo() hugo.HugoInfo {
return s.s.Hugo()
}

func (s *siteWrapper) BaseURL() template.URL {
func (s *siteWrapper) BaseURL() string {
return s.s.BaseURL()
}

Expand Down Expand Up @@ -319,6 +320,7 @@ type testSite struct {
func (s testSite) Author() map[string]interface{} {
return nil
}

func (s testSite) Authors() AuthorList {
return AuthorList{}
}
Expand Down Expand Up @@ -421,7 +423,7 @@ func (t testSite) Taxonomies() TaxonomyList {
return nil
}

func (t testSite) BaseURL() template.URL {
func (t testSite) BaseURL() string {
return ""
}

Expand Down

0 comments on commit b6a7568

Please sign in to comment.