mirror of
https://github.com/gohugoio/hugo.git
synced 2025-01-16 07:30:46 +00:00
parent
d970327d7b
commit
e5d66074ce
3 changed files with 19 additions and 3 deletions
|
@ -150,9 +150,9 @@ Much like regular pages, taxonomy list [permalinks](/content-management/urls/) a
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
{{% warning "`preserveTaxonomyNames` behaviour change" %}}
|
{{% warning "`preserveTaxonomyNames` behaviour change" %}}
|
||||||
Before 0.49, Hugo would title-ize the taxonomy values for titles even if `preserveTaxonomyNames` was active. This no longer the case, which (for instance) makes it possible to have fully lower-case values.
|
Before 0.49, Hugo would make the first character upper case for the taxonomy values for titles even if `preserveTaxonomyNames` was active. This no longer the case, which (for instance) makes it possible to have fully lower-case values.
|
||||||
|
|
||||||
If you actually need to title-ize these values, you can do so using the [`title` template function][].
|
If you actually need to title-ize these values, you can do so using the `strings.FirstUpper` template function.
|
||||||
{{% /warning %}}
|
{{% /warning %}}
|
||||||
|
|
||||||
## Add Taxonomies to Content
|
## Add Taxonomies to Content
|
||||||
|
@ -211,7 +211,6 @@ If you need to add custom metadata to your taxonomy terms, you will need to crea
|
||||||
|
|
||||||
You can later use your custom metadata as shown in the [Taxonomy Terms Templates documentation](/templates/taxonomy-templates/#displaying-custom-metadata-in-taxonomy-terms-templates).
|
You can later use your custom metadata as shown in the [Taxonomy Terms Templates documentation](/templates/taxonomy-templates/#displaying-custom-metadata-in-taxonomy-terms-templates).
|
||||||
|
|
||||||
[`title` template function]: /functions/title/
|
|
||||||
[`urlize` template function]: /functions/urlize/
|
[`urlize` template function]: /functions/urlize/
|
||||||
[content section]: /content-management/sections/
|
[content section]: /content-management/sections/
|
||||||
[content type]: /content-management/types/
|
[content type]: /content-management/types/
|
||||||
|
|
|
@ -155,6 +155,13 @@ func init() {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ns.AddMethodMapping(ctx.FirstUpper,
|
||||||
|
nil,
|
||||||
|
[][2]string{
|
||||||
|
{`{{ "hugo rocks!" | strings.FirstUpper }}`, `Hugo rocks!`},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
ns.AddMethodMapping(ctx.Truncate,
|
ns.AddMethodMapping(ctx.Truncate,
|
||||||
[]string{"truncate"},
|
[]string{"truncate"},
|
||||||
[][2]string{
|
[][2]string{
|
||||||
|
|
|
@ -325,6 +325,16 @@ func (ns *Namespace) Title(s interface{}) (string, error) {
|
||||||
return ns.titleFunc(ss), nil
|
return ns.titleFunc(ss), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FirstUpper returns a string with the first character as upper case.
|
||||||
|
func (ns *Namespace) FirstUpper(s interface{}) (string, error) {
|
||||||
|
ss, err := cast.ToStringE(s)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return helpers.FirstUpper(ss), nil
|
||||||
|
}
|
||||||
|
|
||||||
// ToLower returns a copy of the input s with all Unicode letters mapped to their
|
// ToLower returns a copy of the input s with all Unicode letters mapped to their
|
||||||
// lower case.
|
// lower case.
|
||||||
func (ns *Namespace) ToLower(s interface{}) (string, error) {
|
func (ns *Namespace) ToLower(s interface{}) (string, error) {
|
||||||
|
|
Loading…
Reference in a new issue