mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
Fix path resolution in hugo new
With theme and project with content directories and command on the form `hugo new posts/test.md`. Fixes #9129
This commit is contained in:
@@ -157,11 +157,14 @@ func (b *BaseFs) AbsProjectContentDir(filename string) (string, string) {
|
||||
if !isAbs {
|
||||
// A filename on the form "posts/mypage.md", put it inside
|
||||
// the first content folder, usually <workDir>/content.
|
||||
// The Dirs are ordered with the most important last, so pick that.
|
||||
// Pick the last project dir (which is probably the most important one).
|
||||
contentDirs := b.SourceFilesystems.Content.Dirs
|
||||
firstContentDir := contentDirs[len(contentDirs)-1].Meta().Filename
|
||||
return filename, filepath.Join(firstContentDir, filename)
|
||||
|
||||
for i := len(contentDirs) - 1; i >= 0; i-- {
|
||||
meta := contentDirs[i].Meta()
|
||||
if meta.Module == "project" {
|
||||
return filename, filepath.Join(meta.Filename, filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "", ""
|
||||
|
Reference in New Issue
Block a user