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:
bep
2015-05-31 20:30:53 +02:00
parent 3ea4df35f2
commit be38acdce7
4 changed files with 80 additions and 50 deletions

View File

@@ -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