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

@@ -65,8 +65,10 @@ func kp(in string) string {
func (i Taxonomy) Get(key string) WeightedPages { return i[kp(key)] }
func (i Taxonomy) Count(key string) int { return len(i[kp(key)]) }
func (i Taxonomy) Add(key string, w WeightedPage) {
key = kp(key)
func (i Taxonomy) Add(key string, w WeightedPage, pretty bool) {
if !pretty {
key = kp(key)
}
i[key] = append(i[key], w)
}