mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Rename DefaultPageSize => PagerSize
This was recently introduced. so no breaking change. The thing is: * We do not commonly use the prefix Default* even if it can be overridden in the templates. * PagerSize makes more sense and is also the term used in the code.
This commit is contained in:
parent
8cf94aea73
commit
9f22bc4414
5 changed files with 13 additions and 13 deletions
|
@ -374,8 +374,8 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
|
||||||
|
|
||||||
// Legacy paginate values.
|
// Legacy paginate values.
|
||||||
if c.Paginate != 0 {
|
if c.Paginate != 0 {
|
||||||
hugo.Deprecate("site config key paginate", "Use paginator.defaultPageSize instead.", "v0.128.0")
|
hugo.Deprecate("site config key paginate", "Use paginator.pagerSize instead.", "v0.128.0")
|
||||||
c.Pagination.DefaultPageSize = c.Paginate
|
c.Pagination.PagerSize = c.Paginate
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.PaginatePath != "" {
|
if c.PaginatePath != "" {
|
||||||
|
|
|
@ -122,9 +122,9 @@ func TestPaginationConfigOld(t *testing.T) {
|
||||||
confDe := b.H.Sites[1].Conf.Pagination()
|
confDe := b.H.Sites[1].Conf.Pagination()
|
||||||
|
|
||||||
b.Assert(confEn.Path, qt.Equals, "page-en")
|
b.Assert(confEn.Path, qt.Equals, "page-en")
|
||||||
b.Assert(confEn.DefaultPageSize, qt.Equals, 10)
|
b.Assert(confEn.PagerSize, qt.Equals, 10)
|
||||||
b.Assert(confDe.Path, qt.Equals, "page-de")
|
b.Assert(confDe.Path, qt.Equals, "page-de")
|
||||||
b.Assert(confDe.DefaultPageSize, qt.Equals, 20)
|
b.Assert(confDe.PagerSize, qt.Equals, 20)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPaginationConfigNew(t *testing.T) {
|
func TestPaginationConfigNew(t *testing.T) {
|
||||||
|
@ -133,7 +133,7 @@ func TestPaginationConfigNew(t *testing.T) {
|
||||||
[languages.en]
|
[languages.en]
|
||||||
weight = 1
|
weight = 1
|
||||||
[languages.en.pagination]
|
[languages.en.pagination]
|
||||||
defaultPageSize = 20
|
pagerSize = 20
|
||||||
[languages.de]
|
[languages.de]
|
||||||
weight = 2
|
weight = 2
|
||||||
[languages.de.pagination]
|
[languages.de.pagination]
|
||||||
|
@ -147,9 +147,9 @@ func TestPaginationConfigNew(t *testing.T) {
|
||||||
confDe := b.H.Sites[1].Conf.Pagination()
|
confDe := b.H.Sites[1].Conf.Pagination()
|
||||||
|
|
||||||
b.Assert(confEn.Path, qt.Equals, "page")
|
b.Assert(confEn.Path, qt.Equals, "page")
|
||||||
b.Assert(confEn.DefaultPageSize, qt.Equals, 20)
|
b.Assert(confEn.PagerSize, qt.Equals, 20)
|
||||||
b.Assert(confDe.Path, qt.Equals, "page-de")
|
b.Assert(confDe.Path, qt.Equals, "page-de")
|
||||||
b.Assert(confDe.DefaultPageSize, qt.Equals, 10)
|
b.Assert(confDe.PagerSize, qt.Equals, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPaginationConfigDisableAliases(t *testing.T) {
|
func TestPaginationConfigDisableAliases(t *testing.T) {
|
||||||
|
@ -158,7 +158,7 @@ func TestPaginationConfigDisableAliases(t *testing.T) {
|
||||||
disableKinds = ["taxonomy", "term"]
|
disableKinds = ["taxonomy", "term"]
|
||||||
[pagination]
|
[pagination]
|
||||||
disableAliases = true
|
disableAliases = true
|
||||||
defaultPageSize = 2
|
pagerSize = 2
|
||||||
-- layouts/_default/list.html --
|
-- layouts/_default/list.html --
|
||||||
{{ $paginator := .Paginate site.RegularPages }}
|
{{ $paginator := .Paginate site.RegularPages }}
|
||||||
{{ template "_internal/pagination.html" . }}
|
{{ template "_internal/pagination.html" . }}
|
||||||
|
|
|
@ -331,7 +331,7 @@ var allDecoderSetups = map[string]decodeWeight{
|
||||||
key: "pagination",
|
key: "pagination",
|
||||||
decode: func(d decodeWeight, p decodeConfig) error {
|
decode: func(d decodeWeight, p decodeConfig) error {
|
||||||
p.c.Pagination = config.Pagination{
|
p.c.Pagination = config.Pagination{
|
||||||
DefaultPageSize: 10,
|
PagerSize: 10,
|
||||||
Path: "page",
|
Path: "page",
|
||||||
}
|
}
|
||||||
if p.p.IsSet(d.key) {
|
if p.p.IsSet(d.key) {
|
||||||
|
|
|
@ -413,8 +413,8 @@ func DecodeServer(cfg Provider) (Server, error) {
|
||||||
|
|
||||||
// Pagination configures the pagination behavior.
|
// Pagination configures the pagination behavior.
|
||||||
type Pagination struct {
|
type Pagination struct {
|
||||||
// Default number of elements per page in pagination.
|
// Default number of elements per pager in pagination.
|
||||||
DefaultPageSize int
|
PagerSize int
|
||||||
|
|
||||||
// The path element used during pagination.
|
// The path element used during pagination.
|
||||||
Path string
|
Path string
|
||||||
|
|
|
@ -263,7 +263,7 @@ func splitPageGroups(pageGroups PagesGroup, size int) []paginatedElement {
|
||||||
|
|
||||||
func ResolvePagerSize(conf config.AllProvider, options ...any) (int, error) {
|
func ResolvePagerSize(conf config.AllProvider, options ...any) (int, error) {
|
||||||
if len(options) == 0 {
|
if len(options) == 0 {
|
||||||
return conf.Pagination().DefaultPageSize, nil
|
return conf.Pagination().PagerSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(options) > 1 {
|
if len(options) > 1 {
|
||||||
|
|
Loading…
Reference in a new issue