Support Fish and Chips section

Section names are also used as the title of the list pages, but naming section folders as `Fish and Chips` and similar didn't work very well.

This commit fixes that.

This commit also changes the title casing of the section titles. Some may argue that this is a breaking change, but the old behaviour was also pretty broken,
even for languages that use title capitalizations, as it didn't follow any particular style guide, `fish and chips` became `Fish And Chips` etc.

Now it just turns the first letter into upper case, so `Fish and Chips` will be left as `Fish and Chips`.

People wanting the good old behaviour can use the `title` template func.

Fixes #1176
This commit is contained in:
bep 2015-05-28 23:05:13 +02:00
parent be535832f7
commit be7404e337
8 changed files with 187 additions and 42 deletions

View file

@ -92,7 +92,7 @@ func UnicodeSanitize(s string) string {
target := make([]rune, 0, len(source))
for _, r := range source {
if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '.' || r == '/' || r == '_' || r == '-' || r == '#' {
if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '.' || r == '/' || r == '\\' || r == '_' || r == '-' || r == '#' {
target = append(target, r)
}
}
@ -332,8 +332,8 @@ func GetRelativePath(path, base string) (final string, err error) {
return "", err
}
if strings.HasSuffix(path, "/") && !strings.HasSuffix(name, "/") {
name += "/"
if strings.HasSuffix(filepath.FromSlash(path), FilePathSeparator) && !strings.HasSuffix(name, FilePathSeparator) {
name += FilePathSeparator
}
return name, nil
}