mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-24 13:30:51 +00:00
create: Delete redundant viper calls
Also make easier to read the code
This commit is contained in:
parent
d07ff9d221
commit
a159feffb2
1 changed files with 5 additions and 5 deletions
|
@ -18,7 +18,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -72,17 +71,18 @@ func NewContent(s *hugolib.Site, kind, name string) (err error) {
|
||||||
|
|
||||||
page.SetSourceContent(psr.Content())
|
page.SetSourceContent(psr.Content())
|
||||||
|
|
||||||
if err = page.SafeSaveSourceAs(filepath.Join(s.Cfg.GetString("contentDir"), name)); err != nil {
|
contentPath := s.PathSpec.AbsPathify(filepath.Join(s.Cfg.GetString("contentDir"), name))
|
||||||
|
|
||||||
|
if err = page.SafeSaveSourceAs(contentPath); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jww.FEEDBACK.Println(s.PathSpec.AbsPathify(filepath.Join(s.Cfg.GetString("contentDir"), name)), "created")
|
jww.FEEDBACK.Println(contentPath, "created")
|
||||||
|
|
||||||
editor := s.Cfg.GetString("newContentEditor")
|
editor := s.Cfg.GetString("newContentEditor")
|
||||||
|
|
||||||
if editor != "" {
|
if editor != "" {
|
||||||
jww.FEEDBACK.Printf("Editing %s with %q ...\n", name, editor)
|
jww.FEEDBACK.Printf("Editing %s with %q ...\n", name, editor)
|
||||||
|
|
||||||
cmd := exec.Command(editor, s.PathSpec.AbsPathify(path.Join(s.Cfg.GetString("contentDir"), name)))
|
cmd := exec.Command(editor, contentPath)
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
Loading…
Reference in a new issue