mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-24 21:56:05 +02:00
Add PreserveTaxonomyNames flag
Before this commit, taxonomy names were hyphenated, lower-cased and normalized -- then fixed and titleized on the archive page. So what you entered in the front matter isn't necessarily what you got in the final site. To preserve backwards compability, `PreserveTaxonomyNames` is default `false`. Setting it to `true` will preserve what you type (the first characters is made toupper for titles), but normalized in URLs. This also means that, if you manually construct URLs to the archive pages, you will have to pass the Taxonomy names through the `urlize` func. Fixes #1180
This commit is contained in:
@@ -539,6 +539,10 @@ func (p *Page) update(f interface{}) error {
|
||||
}
|
||||
|
||||
func (p *Page) GetParam(key string) interface{} {
|
||||
return p.getParam(key, true)
|
||||
}
|
||||
|
||||
func (p *Page) getParam(key string, stringToLower bool) interface{} {
|
||||
v := p.Params[strings.ToLower(key)]
|
||||
|
||||
if v == nil {
|
||||
@@ -549,7 +553,10 @@ func (p *Page) GetParam(key string) interface{} {
|
||||
case bool:
|
||||
return cast.ToBool(v)
|
||||
case string:
|
||||
return strings.ToLower(cast.ToString(v))
|
||||
if stringToLower {
|
||||
return strings.ToLower(cast.ToString(v))
|
||||
}
|
||||
return cast.ToString(v)
|
||||
case int64, int32, int16, int8, int:
|
||||
return cast.ToInt(v)
|
||||
case float64, float32:
|
||||
@@ -557,7 +564,10 @@ func (p *Page) GetParam(key string) interface{} {
|
||||
case time.Time:
|
||||
return cast.ToTime(v)
|
||||
case []string:
|
||||
return helpers.SliceToLower(v.([]string))
|
||||
if stringToLower {
|
||||
return helpers.SliceToLower(v.([]string))
|
||||
}
|
||||
return v.([]string)
|
||||
case map[string]interface{}: // JSON and TOML
|
||||
return v
|
||||
case map[interface{}]interface{}: // YAML
|
||||
|
Reference in New Issue
Block a user