Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrashant Karmakar <webster15july@gmail.com>2016-11-01 16:18:24 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-11-01 16:18:24 +0300
commit186db7cd7ad56051d5a064ee5120e6ec73f575a0 (patch)
tree58ccdae205c55af5a01be7f87a9a5ce1a27051b9
parentcda3b36fe2c1fd708fe5c9b9388c3880004bd1c6 (diff)
Fix page names that contain dot
changes: - in hugolib/page.go, `func permalink` and `func TargetPath` Fixed the attempt to *replace* the extension of something that was *already* a basename. - in source/file.go, `func NewFile` added check for allowed languages before translating filename Fixes #2555
-rw-r--r--hugolib/page.go4
-rw-r--r--source/file.go9
2 files changed, 8 insertions, 5 deletions
diff --git a/hugolib/page.go b/hugolib/page.go
index 111cb52bd..79889cd3f 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -586,7 +586,7 @@ func (p *Page) permalink() (*url.URL, error) {
permalink = helpers.URLPrep(viper.GetBool("uglyURLs"), path.Join(dir, p.Slug+"."+p.Extension()))
} else {
t := p.Source.TranslationBaseName()
- permalink = helpers.URLPrep(viper.GetBool("uglyURLs"), path.Join(dir, helpers.ReplaceExtension(strings.TrimSpace(t), p.Extension())))
+ permalink = helpers.URLPrep(viper.GetBool("uglyURLs"), path.Join(dir, (strings.TrimSpace(t)+"."+p.Extension())))
}
}
@@ -1163,7 +1163,7 @@ func (p *Page) TargetPath() (outfile string) {
outfile = strings.TrimSpace(p.Slug) + "." + p.Extension()
} else {
// Fall back to filename
- outfile = helpers.ReplaceExtension(p.Source.TranslationBaseName(), p.Extension())
+ outfile = (p.Source.TranslationBaseName() + "." + p.Extension())
}
return p.addLangFilepathPrefix(filepath.Join(strings.ToLower(
diff --git a/source/file.go b/source/file.go
index 7e3e7d7c4..c309bbd03 100644
--- a/source/file.go
+++ b/source/file.go
@@ -126,11 +126,14 @@ func NewFile(relpath string) *File {
f.ext = strings.TrimPrefix(filepath.Ext(f.LogicalName()), ".")
f.baseName = helpers.Filename(f.LogicalName())
- f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".")
- if f.lang == "" {
+ lang := strings.TrimPrefix(filepath.Ext(f.baseName), ".")
+ if _, ok := viper.GetStringMap("languages")[lang]; lang == "" || !ok {
f.lang = viper.GetString("defaultContentLanguage")
+ f.translationBaseName = f.baseName
+ } else {
+ f.lang = lang
+ f.translationBaseName = helpers.Filename(f.baseName)
}
- f.translationBaseName = helpers.Filename(f.baseName)
f.section = helpers.GuessSection(f.Dir())
f.uniqueID = helpers.Md5String(f.LogicalName())