mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
tplimpl: Fix lookup with non-standard layout folder
This commit is contained in:
parent
930a3df1b7
commit
4923273688
1 changed files with 9 additions and 10 deletions
|
@ -476,25 +476,23 @@ func (t *GoHTMLTemplate) loadTemplates(absPath string, prefix string) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
workingDir := t.PathSpec.WorkingDir()
|
var (
|
||||||
themeDir := t.PathSpec.GetThemeDir()
|
workingDir = t.PathSpec.WorkingDir()
|
||||||
|
themeDir = t.PathSpec.GetThemeDir()
|
||||||
|
layoutDir = t.PathSpec.LayoutDir()
|
||||||
|
)
|
||||||
|
|
||||||
if themeDir != "" && strings.HasPrefix(absPath, themeDir) {
|
if themeDir != "" && strings.HasPrefix(absPath, themeDir) {
|
||||||
workingDir = themeDir
|
workingDir = themeDir
|
||||||
|
layoutDir = "layouts"
|
||||||
}
|
}
|
||||||
|
|
||||||
li := strings.LastIndex(path, t.PathSpec.LayoutDir()) + len(t.PathSpec.LayoutDir()) + 1
|
li := strings.LastIndex(path, layoutDir) + len(layoutDir) + 1
|
||||||
|
|
||||||
if li < 0 {
|
|
||||||
// Possibly a theme
|
|
||||||
li = strings.LastIndex(path, "layouts") + 8
|
|
||||||
}
|
|
||||||
|
|
||||||
relPath := path[li:]
|
relPath := path[li:]
|
||||||
|
|
||||||
descriptor := output.TemplateLookupDescriptor{
|
descriptor := output.TemplateLookupDescriptor{
|
||||||
WorkingDir: workingDir,
|
WorkingDir: workingDir,
|
||||||
LayoutDir: t.PathSpec.LayoutDir(),
|
LayoutDir: layoutDir,
|
||||||
RelPath: relPath,
|
RelPath: relPath,
|
||||||
Prefix: prefix,
|
Prefix: prefix,
|
||||||
Theme: t.PathSpec.Theme(),
|
Theme: t.PathSpec.Theme(),
|
||||||
|
@ -509,6 +507,7 @@ func (t *GoHTMLTemplate) loadTemplates(absPath string, prefix string) {
|
||||||
tplID, err := output.CreateTemplateNames(descriptor)
|
tplID, err := output.CreateTemplateNames(descriptor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log.ERROR.Printf("Failed to resolve template in path %q: %s", path, err)
|
t.Log.ERROR.Printf("Failed to resolve template in path %q: %s", path, err)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue