mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
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
This commit is contained in:
@@ -421,9 +421,20 @@ func (p *pageState) setMetaPostParams() error {
|
||||
var sitemapSet bool
|
||||
|
||||
var draft, published, isCJKLanguage *bool
|
||||
var userParams map[string]any
|
||||
for k, v := range pm.params {
|
||||
loki := strings.ToLower(k)
|
||||
|
||||
if loki == "params" {
|
||||
vv, err := maps.ToStringMapE(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userParams = vv
|
||||
delete(pm.params, k)
|
||||
continue
|
||||
}
|
||||
|
||||
if loki == "published" { // Intentionally undocumented
|
||||
vv, err := cast.ToBoolE(v)
|
||||
if err == nil {
|
||||
@@ -589,6 +600,10 @@ func (p *pageState) setMetaPostParams() error {
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range userParams {
|
||||
pm.params[strings.ToLower(k)] = v
|
||||
}
|
||||
|
||||
if !sitemapSet {
|
||||
pm.sitemap = p.s.conf.Sitemap
|
||||
}
|
||||
|
Reference in New Issue
Block a user