hugolib: Fix bundle path when slug is set

Fixes #4870
This commit is contained in:
Bjørn Erik Pedersen
2019-05-31 09:40:58 +02:00
parent 8d898ad667
commit 3e6cb2cb77
4 changed files with 54 additions and 7 deletions

View File

@@ -15,6 +15,9 @@ package hugolib
import (
"net/url"
"strings"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/resources/page"
)
@@ -95,8 +98,9 @@ func (l pagePaths) OutputFormats() page.OutputFormats {
func createTargetPathDescriptor(s *Site, p page.Page, pm *pageMeta) (page.TargetPathDescriptor, error) {
var (
dir string
baseName string
dir string
baseName string
contentBaseName string
)
d := s.Deps
@@ -104,6 +108,14 @@ func createTargetPathDescriptor(s *Site, p page.Page, pm *pageMeta) (page.Target
if !p.File().IsZero() {
dir = p.File().Dir()
baseName = p.File().TranslationBaseName()
contentBaseName = p.File().ContentBaseName()
}
if baseName != contentBaseName {
// See https://github.com/gohugoio/hugo/issues/4870
// A leaf bundle
dir = strings.TrimSuffix(dir, contentBaseName+helpers.FilePathSeparator)
baseName = contentBaseName
}
alwaysInSubDir := p.Kind() == kindSitemap