fixing /default/ in the path for default post types

pull/8/head
Stephen Searles 8 years ago
parent c8881bedfc
commit 31515121ec
  1. 3
      caddyhugo.go
  2. 3
      templates.go

@ -467,6 +467,9 @@ func (ch CaddyHugo) NewContent(w http.ResponseWriter, r *http.Request) (int, err
} }
filename := path.Join(ctype, name) filename := path.Join(ctype, name)
if ctype == "default" {
filename = name
}
cmd := exec.Command("hugo", "new", filename) cmd := exec.Command("hugo", "new", filename)
cmd.Dir = ch.Site.Root cmd.Dir = ch.Site.Root

@ -107,6 +107,9 @@ func baseNoExt(name string) string {
func (t tmplData) IframeSource() string { func (t tmplData) IframeSource() string {
name := baseNoExt(t.docref.name) name := baseNoExt(t.docref.name)
ctype := baseNoExt(path.Dir(t.docref.name)) ctype := baseNoExt(path.Dir(t.docref.name))
if ctype == "content" {
return fmt.Sprintf("/hugo/draft/%s/%s/", base64.RawURLEncoding.EncodeToString([]byte(t.docref.name)), strings.Replace(name, " ", "-", -1))
}
return fmt.Sprintf("/hugo/draft/%s/%s/%s/", base64.RawURLEncoding.EncodeToString([]byte(t.docref.name)), ctype, strings.Replace(name, " ", "-", -1)) return fmt.Sprintf("/hugo/draft/%s/%s/%s/", base64.RawURLEncoding.EncodeToString([]byte(t.docref.name)), ctype, strings.Replace(name, " ", "-", -1))
} }

Loading…
Cancel
Save