diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-06-08 22:28:02 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-06-09 12:28:24 +0200 |
commit | 9f22bc4414616210546899b83e37ef054491bf07 (patch) | |
tree | f80f103e5d563a3cef30676b69d5fadb4028a9b8 | |
parent | 8cf94aea7377a6adbcd41f11908139c0790cc809 (diff) | |
download | hugo-9f22bc4414616210546899b83e37ef054491bf07.tar.gz hugo-9f22bc4414616210546899b83e37ef054491bf07.zip |
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.
-rw-r--r-- | config/allconfig/allconfig.go | 4 | ||||
-rw-r--r-- | config/allconfig/allconfig_integration_test.go | 12 | ||||
-rw-r--r-- | config/allconfig/alldecoders.go | 4 | ||||
-rw-r--r-- | config/commonConfig.go | 4 | ||||
-rw-r--r-- | resources/page/pagination.go | 2 |
5 files changed, 13 insertions, 13 deletions
diff --git a/config/allconfig/allconfig.go b/config/allconfig/allconfig.go index 64288e887..9f899939b 100644 --- a/config/allconfig/allconfig.go +++ b/config/allconfig/allconfig.go @@ -374,8 +374,8 @@ func (c *Config) CompileConfig(logger loggers.Logger) error { // Legacy paginate values. if c.Paginate != 0 { - hugo.Deprecate("site config key paginate", "Use paginator.defaultPageSize instead.", "v0.128.0") - c.Pagination.DefaultPageSize = c.Paginate + hugo.Deprecate("site config key paginate", "Use paginator.pagerSize instead.", "v0.128.0") + c.Pagination.PagerSize = c.Paginate } if c.PaginatePath != "" { diff --git a/config/allconfig/allconfig_integration_test.go b/config/allconfig/allconfig_integration_test.go index a71a28ed7..7dc0d230e 100644 --- a/config/allconfig/allconfig_integration_test.go +++ b/config/allconfig/allconfig_integration_test.go @@ -122,9 +122,9 @@ func TestPaginationConfigOld(t *testing.T) { confDe := b.H.Sites[1].Conf.Pagination() 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.DefaultPageSize, qt.Equals, 20) + b.Assert(confDe.PagerSize, qt.Equals, 20) } func TestPaginationConfigNew(t *testing.T) { @@ -133,7 +133,7 @@ func TestPaginationConfigNew(t *testing.T) { [languages.en] weight = 1 [languages.en.pagination] - defaultPageSize = 20 + pagerSize = 20 [languages.de] weight = 2 [languages.de.pagination] @@ -147,9 +147,9 @@ func TestPaginationConfigNew(t *testing.T) { confDe := b.H.Sites[1].Conf.Pagination() 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.DefaultPageSize, qt.Equals, 10) + b.Assert(confDe.PagerSize, qt.Equals, 10) } func TestPaginationConfigDisableAliases(t *testing.T) { @@ -158,7 +158,7 @@ func TestPaginationConfigDisableAliases(t *testing.T) { disableKinds = ["taxonomy", "term"] [pagination] disableAliases = true -defaultPageSize = 2 +pagerSize = 2 -- layouts/_default/list.html -- {{ $paginator := .Paginate site.RegularPages }} {{ template "_internal/pagination.html" . }} diff --git a/config/allconfig/alldecoders.go b/config/allconfig/alldecoders.go index 46dd59bbc..c09aa0ff0 100644 --- a/config/allconfig/alldecoders.go +++ b/config/allconfig/alldecoders.go @@ -331,8 +331,8 @@ var allDecoderSetups = map[string]decodeWeight{ key: "pagination", decode: func(d decodeWeight, p decodeConfig) error { p.c.Pagination = config.Pagination{ - DefaultPageSize: 10, - Path: "page", + PagerSize: 10, + Path: "page", } if p.p.IsSet(d.key) { if err := mapstructure.WeakDecode(p.p.Get(d.key), &p.c.Pagination); err != nil { diff --git a/config/commonConfig.go b/config/commonConfig.go index 40650c575..6e41ac7f0 100644 --- a/config/commonConfig.go +++ b/config/commonConfig.go @@ -413,8 +413,8 @@ func DecodeServer(cfg Provider) (Server, error) { // Pagination configures the pagination behavior. type Pagination struct { - // Default number of elements per page in pagination. - DefaultPageSize int + // Default number of elements per pager in pagination. + PagerSize int // The path element used during pagination. Path string diff --git a/resources/page/pagination.go b/resources/page/pagination.go index d24879e62..779481792 100644 --- a/resources/page/pagination.go +++ b/resources/page/pagination.go @@ -263,7 +263,7 @@ func splitPageGroups(pageGroups PagesGroup, size int) []paginatedElement { func ResolvePagerSize(conf config.AllProvider, options ...any) (int, error) { if len(options) == 0 { - return conf.Pagination().DefaultPageSize, nil + return conf.Pagination().PagerSize, nil } if len(options) > 1 { |