Fix Permalink for resource, baseURL with path and canonifyURLs set

Fixes #5226
This commit is contained in:
Bjørn Erik Pedersen
2018-11-15 13:35:28 +01:00
parent 12742bac71
commit 5df2b79dd2
10 changed files with 212 additions and 198 deletions

View File

@@ -34,7 +34,6 @@ type Paths struct {
BaseURL
// If the baseURL contains a base path, e.g. https://example.com/docs, then "/docs" will be the BasePath.
// This will not be set if canonifyURLs is enabled.
BasePath string
// Directories
@@ -192,6 +191,15 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
return p, nil
}
// GetBasePath returns any path element in baseURL if needed.
func (p *Paths) GetBasePath(isRelativeURL bool) string {
if isRelativeURL && p.CanonifyURLs {
// The baseURL will be prepended later.
return ""
}
return p.BasePath
}
func (p *Paths) Lang() string {
if p == nil || p.Language == nil {
return ""