1
0
mirror of https://github.com/gohugoio/hugo.git synced 2024-05-11 05:54:58 +00:00

media, hugolib: Support extension-less media types

This change is motivated by Netlify's `_redirects` files, which is currently not possible to generate with Hugo.

This commit adds a `Delimiter` field to media type, which defaults to ".", but can be blanked out.

Fixes #3614
This commit is contained in:
Bjørn Erik Pedersen
2017-06-20 08:45:52 +02:00
parent 516e6c6dc5
commit 0f40e1fadf
7 changed files with 183 additions and 34 deletions

View File

@@ -164,7 +164,7 @@ func createTargetPath(d targetPathDescriptor) string {
if d.URL != "" {
pagePath = filepath.Join(pagePath, d.URL)
if strings.HasSuffix(d.URL, "/") || !strings.Contains(d.URL, ".") {
pagePath = filepath.Join(pagePath, d.Type.BaseName+"."+d.Type.MediaType.Suffix)
pagePath = filepath.Join(pagePath, d.Type.BaseName+d.Type.MediaType.FullSuffix())
}
} else {
if d.ExpandedPermalink != "" {
@@ -184,9 +184,9 @@ func createTargetPath(d targetPathDescriptor) string {
}
if isUgly {
pagePath += "." + d.Type.MediaType.Suffix
pagePath += d.Type.MediaType.Delimiter + d.Type.MediaType.Suffix
} else {
pagePath = filepath.Join(pagePath, d.Type.BaseName+"."+d.Type.MediaType.Suffix)
pagePath = filepath.Join(pagePath, d.Type.BaseName+d.Type.MediaType.FullSuffix())
}
if d.LangPrefix != "" {
@@ -207,7 +207,7 @@ func createTargetPath(d targetPathDescriptor) string {
base = helpers.FilePathSeparator + d.Type.BaseName
}
pagePath += base + "." + d.Type.MediaType.Suffix
pagePath += base + d.Type.MediaType.FullSuffix()
if d.LangPrefix != "" {
pagePath = filepath.Join(d.LangPrefix, pagePath)