summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-06-28 10:27:39 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-06-29 10:14:19 +0200
commit7917961d59b0dc216e49f59dc0255f9b46534115 (patch)
treeee9a348c2555fdbbac8022ade50c5d440a81ae4e /config
parent80ecb958951783eb03e23a81800102d0e33db6e1 (diff)
Misc permalinks adjustments
* Move config loading to the page package * Fix a lower bound panic for the `:sections` slice syntax. * Always return the `:title` * Add some permalinks integration tests * Also see issues below Fixes #9448 Fixes #11184 See #8523
Diffstat (limited to 'config')
-rw-r--r--config/allconfig/alldecoders.go46
1 files changed, 3 insertions, 43 deletions
diff --git a/config/allconfig/alldecoders.go b/config/allconfig/alldecoders.go
index bda3122d3..a40a02372 100644
--- a/config/allconfig/alldecoders.go
+++ b/config/allconfig/alldecoders.go
@@ -206,49 +206,9 @@ var allDecoderSetups = map[string]decodeWeight{
"permalinks": {
key: "permalinks",
decode: func(d decodeWeight, p decodeConfig) error {
- p.c.Permalinks = make(map[string]map[string]string)
-
- p.c.Permalinks["page"] = make(map[string]string)
- p.c.Permalinks["section"] = make(map[string]string)
- p.c.Permalinks["taxonomy"] = make(map[string]string)
- p.c.Permalinks["term"] = make(map[string]string)
-
- config := maps.CleanConfigStringMap(p.p.GetStringMap(d.key))
- for k, v := range config {
- switch v := v.(type) {
- case string:
- // [permalinks]
- // key = '...'
-
- // To sucessfully be backward compatible, "default" patterns need to be set for both page and term
- p.c.Permalinks["page"][k] = v
- p.c.Permalinks["term"][k] = v
-
- case maps.Params:
- // [permalinks.key]
- // xyz = ???
-
- if (k == "page") || (k == "section") || (k == "taxonomy") || (k == "term") {
- // TODO: warn if we overwrite an already set value
- for k2, v2 := range v {
- switch v2 := v2.(type) {
- case string:
- p.c.Permalinks[k][k2] = v2
-
- default:
- return fmt.Errorf("permalinks configuration invalid: unknown value %q for key %q for kind %q", v2, k2, k)
- }
- }
- } else {
- return fmt.Errorf("permalinks configuration only allows per-kind configuration 'page', 'section', 'taxonomy' and 'term'; unknown kind: %q", k)
- }
-
- default:
- return fmt.Errorf("permalinks configuration invalid: unknown value %q for key %q", v, k)
- }
- }
-
- return nil
+ var err error
+ p.c.Permalinks, err = page.DecodePermalinksConfig(p.p.GetStringMap(d.key))
+ return err
},
},
"sitemap": {