diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-01-28 17:32:26 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-01-28 21:38:40 +0100 |
commit | 6dedb4efc7b6a9fbe58a2daf0f77182638840fd9 (patch) | |
tree | 498ce0c315623d20c2ab9ed166f3133a9185b689 /resources | |
parent | 292626e679e5203faf3d42f004c12027da3e4300 (diff) | |
download | hugo-6dedb4efc7b6a9fbe58a2daf0f77182638840fd9.tar.gz hugo-6dedb4efc7b6a9fbe58a2daf0f77182638840fd9.zip |
Add the [params] concept to front matter
This is deliberately very simple, but should not break anything. We need to introduce this in baby steps, but this should allow us to introduce this in the documentation.
Note that the `params` section's key/values will be added to `.Params` last. This means that you can have different values for "Hugo's summary" and the custom ".Params.summary" if you want to.
Updates #11055
Diffstat (limited to 'resources')
-rw-r--r-- | resources/page/page_matcher.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/resources/page/page_matcher.go b/resources/page/page_matcher.go index f5e8e2697..8529b0e28 100644 --- a/resources/page/page_matcher.go +++ b/resources/page/page_matcher.go @@ -144,7 +144,16 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er // those values will now be moved to the top level. // This should be very unlikely as it would lead to constructs like .Params.params.foo, // and most people see params as an Hugo internal keyword. - pcfg.Params = maps.ToStringMap(v) + params := maps.ToStringMap(v) + if pcfg.Params == nil { + pcfg.Params = params + } else { + for k, v := range params { + if _, found := pcfg.Params[k]; !found { + pcfg.Params[k] = v + } + } + } case "_target", "target": var target PageMatcher if err := decodePageMatcher(v, &target); err != nil { |