aboutsummaryrefslogtreecommitdiffhomepage
path: root/config
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-08-17 15:16:09 +0200
committerBjørn Erik Pedersen <[email protected]>2024-08-17 16:47:50 +0200
commit01008ba51259e68191b14f8a4725d6116c0c2466 (patch)
tree4471fb47f602d49b26c51b9c5a1d97dd4f9758cc /config
parent53c0ddfcb4ec2f4d021f6f51c04f0ba9db741b20 (diff)
downloadhugo-01008ba51259e68191b14f8a4725d6116c0c2466.tar.gz
hugo-01008ba51259e68191b14f8a4725d6116c0c2466.zip
Add config options page.nextPrevSortOrder/nextPrevInSectionSortOrder
See #12776
Diffstat (limited to 'config')
-rw-r--r--config/allconfig/allconfig.go3
-rw-r--r--config/allconfig/alldecoders.go19
-rw-r--r--config/commonConfig.go15
3 files changed, 37 insertions, 0 deletions
diff --git a/config/allconfig/allconfig.go b/config/allconfig/allconfig.go
index afa72fb11..802000f97 100644
--- a/config/allconfig/allconfig.go
+++ b/config/allconfig/allconfig.go
@@ -182,6 +182,9 @@ type Config struct {
// Pagination configuration.
Pagination config.Pagination `mapstructure:"-"`
+ // Page configuration.
+ Page config.PageConfig `mapstructure:"-"`
+
// Privacy configuration.
Privacy privacy.Config `mapstructure:"-"`
diff --git a/config/allconfig/alldecoders.go b/config/allconfig/alldecoders.go
index c09aa0ff0..45cdd0de6 100644
--- a/config/allconfig/alldecoders.go
+++ b/config/allconfig/alldecoders.go
@@ -327,6 +327,25 @@ var allDecoderSetups = map[string]decodeWeight{
return err
},
},
+ "page": {
+ key: "page",
+ decode: func(d decodeWeight, p decodeConfig) error {
+ p.c.Page = config.PageConfig{
+ NextPrevSortOrder: "desc",
+ NextPrevInSectionSortOrder: "desc",
+ }
+ if p.p.IsSet(d.key) {
+ if err := mapstructure.WeakDecode(p.p.Get(d.key), &p.c.Page); err != nil {
+ return err
+ }
+ }
+
+ return nil
+ },
+ getCompiler: func(c *Config) configCompiler {
+ return &c.Page
+ },
+ },
"pagination": {
key: "pagination",
decode: func(d decodeWeight, p decodeConfig) error {
diff --git a/config/commonConfig.go b/config/commonConfig.go
index a615c51a7..9dea4a2fc 100644
--- a/config/commonConfig.go
+++ b/config/commonConfig.go
@@ -422,3 +422,18 @@ type Pagination struct {
// Whether to disable generation of alias for the first pagination page.
DisableAliases bool
}
+
+// PageConfig configures the behavior of pages.
+type PageConfig struct {
+ // Sort order for Page.Next and Page.Prev. Default "desc" (the default page sort order in Hugo).
+ NextPrevSortOrder string
+
+ // Sort order for Page.NextInSection and Page.PrevInSection. Default "desc".
+ NextPrevInSectionSortOrder string
+}
+
+func (c *PageConfig) CompileConfig(loggers.Logger) error {
+ c.NextPrevInSectionSortOrder = strings.ToLower(c.NextPrevInSectionSortOrder)
+ c.NextPrevSortOrder = strings.ToLower(c.NextPrevSortOrder)
+ return nil
+}