diff --git a/example/content/de/main/01_home/README.md b/example/content/de/main/01_home/README.md index dd7ef4a..206cf46 100644 --- a/example/content/de/main/01_home/README.md +++ b/example/content/de/main/01_home/README.md @@ -2,6 +2,9 @@ Meta: Title: Home +Data: + Image: /schönes_Bild.jpg + Subtitle: und Weiteres --- # Home diff --git a/example/templates/index.html b/example/templates/index.html index c42d219..73965de 100644 --- a/example/templates/index.html +++ b/example/templates/index.html @@ -1,8 +1,14 @@ {{ Meta.Title }} + + {{{ Body }}} +
+
+            {{{ Data }}}
+        
\ No newline at end of file diff --git a/main.go b/main.go index 39a0ce1..af6a5ca 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,6 @@ import ( "github.com/aymerick/raymond" "github.com/davecgh/go-spew/spew" - "github.com/imdario/mergo" "github.com/op/go-logging" "gopkg.in/russross/blackfriday.v2" "gopkg.in/yaml.v2" @@ -68,6 +67,8 @@ type PathConfig struct { Ignore *string `yaml:"Ignore"` OutputExtension *string `yaml:"OutputExtension"` } `yaml:"Filename"` + + Data interface{} `yaml:"Data"` } // PathConfigTree is complete config tree of content dir @@ -325,9 +326,10 @@ func processContent(conf *PathConfigTree) { // read yaml header as data for template ctx := make(map[string]interface{}) - mergo.Map(&ctx, newConfig) + ctx["Meta"] = newConfig.Meta + ctx["Data"] = newConfig.Data ctx["Body"] = string(html) - //log.Warning(spew.Sdump(ctx)) + log.Warning(spew.Sdump(ctx)) result, err := template.Exec(ctx) if err != nil { @@ -466,14 +468,4 @@ func main() { processContent(contentConfig) - /* - - input, err := ioutil.ReadFile("README.md") - if err != nil { - panic(err) - } - //html := blackfriday.Run(input, blackfriday.WithRenderer(bfchroma.NewRenderer())) - html := blackfriday.Run(input) - fmt.Println(string(html)) - */ }