fix settings error

pull/20/head
Henrique Dias 2015-09-15 21:28:54 +01:00
parent e045d76bcd
commit 7a5e184610
2 changed files with 16 additions and 5 deletions

View File

@ -30,6 +30,8 @@ func rawToPretty(config interface{}, master string, parent string) interface{} {
if utils.IsSlice(config) { if utils.IsSlice(config) {
settings := make([]interface{}, len(config.([]interface{}))) settings := make([]interface{}, len(config.([]interface{})))
// TODO: improve this function
for index, element := range config.([]interface{}) { for index, element := range config.([]interface{}) {
c := new(frontmatter) c := new(frontmatter)
c.Name = master c.Name = master

View File

@ -13,10 +13,6 @@ import (
"github.com/spf13/hugo/commands" "github.com/spf13/hugo/commands"
) )
type test struct {
Test string
}
// Execute the page // Execute the page
func Execute(w http.ResponseWriter, r *http.Request) (int, error) { func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
language := getConfigFrontMatter() language := getConfigFrontMatter()
@ -62,7 +58,7 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
return 500, err return 500, err
} }
f, err := frontmatter.Pretty(content) f, err := frontmatter.Pretty(appendFrontMatterRune(content, language))
if err != nil { if err != nil {
log.Print(err) log.Print(err)
@ -94,3 +90,16 @@ func getConfigFrontMatter() string {
return frontmatter return frontmatter
} }
func appendFrontMatterRune(frontmatter []byte, language string) []byte {
switch language {
case "yaml":
return []byte("---\n" + string(frontmatter) + "\n---")
case "toml":
return []byte("+++\n" + string(frontmatter) + "\n+++")
case "json":
return frontmatter
}
return frontmatter
}