fix settings error
This commit is contained in:
parent
e045d76bcd
commit
7a5e184610
|
@ -30,6 +30,8 @@ func rawToPretty(config interface{}, master string, parent string) interface{} {
|
|||
if utils.IsSlice(config) {
|
||||
settings := make([]interface{}, len(config.([]interface{})))
|
||||
|
||||
// TODO: improve this function
|
||||
|
||||
for index, element := range config.([]interface{}) {
|
||||
c := new(frontmatter)
|
||||
c.Name = master
|
||||
|
|
|
@ -13,10 +13,6 @@ import (
|
|||
"github.com/spf13/hugo/commands"
|
||||
)
|
||||
|
||||
type test struct {
|
||||
Test string
|
||||
}
|
||||
|
||||
// Execute the page
|
||||
func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
language := getConfigFrontMatter()
|
||||
|
@ -62,7 +58,7 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
|
|||
return 500, err
|
||||
}
|
||||
|
||||
f, err := frontmatter.Pretty(content)
|
||||
f, err := frontmatter.Pretty(appendFrontMatterRune(content, language))
|
||||
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
|
@ -94,3 +90,16 @@ func getConfigFrontMatter() string {
|
|||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue