Add option to not generate aliases for first page of pagination pages

Also consolidate the pagination configuration into a struct.

Closes #12572
This commit is contained in:
Bjørn Erik Pedersen
2024-06-07 17:38:33 +02:00
parent 1cdd3d0a9e
commit 9c4e14eb4f
9 changed files with 135 additions and 14 deletions

View File

@@ -179,6 +179,9 @@ type Config struct {
// Server configuration.
Server config.Server `mapstructure:"-"`
// Pagination configuration.
Pagination config.Pagination `mapstructure:"-"`
// Privacy configuration.
Privacy privacy.Config `mapstructure:"-"`
@@ -369,6 +372,17 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
return err
}
// 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
}
if c.PaginatePath != "" {
hugo.Deprecate("site config key paginatePath", "Use paginator.path instead.", "v0.128.0")
c.Pagination.Path = c.PaginatePath
}
c.C = &ConfigCompiled{
Timeout: timeout,
BaseURL: baseURL,
@@ -557,9 +571,11 @@ type RootConfig struct {
HasCJKLanguage bool
// The default number of pages per page when paginating.
// Deprecated: Use the Pagination struct.
Paginate int
// The path to use when creating pagination URLs, e.g. "page" in /page/2/.
// Deprecated: Use the Pagination struct.
PaginatePath string
// Whether to pluralize default list titles.