diff options
Diffstat (limited to 'create/content.go')
-rw-r--r-- | create/content.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/create/content.go b/create/content.go index 8af417294..29fe47394 100644 --- a/create/content.go +++ b/create/content.go @@ -63,7 +63,22 @@ func NewContent( return err } - contentPath := s.PathSpec.AbsPathify(filepath.Join(s.Cfg.GetString("contentDir"), targetPath)) + // The site may have multiple content dirs, and we currently do not know which contentDir the + // user wants to create this content in. We should improve on this, but we start by testing if the + // provided path points to an existing dir. If so, use it as is. + var contentPath string + var exists bool + targetDir := filepath.Dir(targetPath) + + if targetDir != "" && targetDir != "." { + exists, _ = helpers.Exists(targetDir, ps.Fs.Source) + } + + if exists { + contentPath = targetPath + } else { + contentPath = s.PathSpec.AbsPathify(filepath.Join(s.Cfg.GetString("contentDir"), targetPath)) + } if err := helpers.SafeWriteToDisk(contentPath, bytes.NewReader(content), s.Fs.Source); err != nil { return err |