fixing more kinds of filenames

pull/8/head
Stephen Searles 7 years ago
parent 3f8cb4f265
commit 406af7b834
  1. 20
      caddyhugo.go
  2. 2
      templates.go

@ -19,13 +19,13 @@ import (
"git.stephensearles.com/stephen/acedoc"
"git.stephensearles.com/stephen/caddy-hugo2/assets"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/hugolib"
"github.com/gorilla/websocket"
"github.com/mholt/caddy"
"github.com/mholt/caddy/caddyhttp/httpserver"
"github.com/spf13/afero"
"github.com/spf13/hugo/deps"
"github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/hugolib"
)
const (
@ -321,7 +321,15 @@ func (ch *CaddyHugo) serveDraft(w http.ResponseWriter, r *http.Request) (int, er
prefix := "/hugo/draft/" + encoded
r.URL.Path = r.URL.Path[len(prefix):]
page := ch.HugoSites.GetContentPage(name)
if page == nil {
fmt.Fprintf(w, "can't find %q to display a draft", name)
return 404, nil
}
r.URL.Path = page.RelPermalink()
http.FileServer(http.Dir(docref.tmpdir)).ServeHTTP(w, r)
return 200, nil
}
@ -512,11 +520,9 @@ func (ch CaddyHugo) NewContent(w http.ResponseWriter, r *http.Request) (int, err
name += ".md"
}
name = strings.ToLower(name)
filename := path.Join(ctype, name)
filename := path.Join(ctype, strings.ToLower(name))
if ctype == "default" {
filename = name
filename = strings.ToLower(name)
}
_, err := os.Stat(path.Join(ch.Site.Root, "content", filename))

@ -12,8 +12,8 @@ import (
"git.stephensearles.com/stephen/acedoc"
"github.com/gohugoio/hugo/hugolib"
"github.com/mholt/caddy/caddyhttp/httpserver"
"github.com/spf13/hugo/hugolib"
)
type Content struct {

Loading…
Cancel
Save