package caddyhugo import ( "fmt" "net/http" "os" "path" "path/filepath" "git.stephensearles.com/stephen/acedoc" "github.com/mholt/caddy/caddyhttp/httpserver" ) func (t tmplData) Content() ([]string, error) { var files []string err := filepath.Walk(path.Join(t.Site.Root, "content"), func(name string, fi os.FileInfo, err error) error { if fi.IsDir() { return nil } files = append(files, name) return nil }) if err != nil { fmt.Println(err) return nil, err } return files, nil } func (t tmplData) ContentTypes() ([]string, error) { layoutDir, err := os.Open(path.Join(t.Site.Root, "archetypes")) if err != nil { fmt.Println("opening layout dir", err) return nil, err } defer layoutDir.Close() names, err := layoutDir.Readdirnames(0) if err != nil { fmt.Println("reading dir", err) return nil, err } out := []string{"default"} for _, name := range names { out = append(out, name[:len(name)-len(filepath.Ext(name))]) } return out, nil } type tmplData struct { Site *httpserver.SiteConfig R *http.Request CaddyHugo Doc *acedoc.Document } func (t tmplData) LoadContent() (string, error) { return t.Doc.Contents(), nil } var EditPage = `
{{ .LoadContent }}
` var AdminPage = `not implemented` var AuthorPage = `

Create content:

Edit content:

`