data in header

This commit is contained in:
Sebastian Frank 2019-02-12 13:05:26 +01:00
parent 35561aa97f
commit 849e8a945e
Signed by: apairon
GPG Key ID: 7270D06DDA7FE8C3
3 changed files with 14 additions and 13 deletions

View File

@ -2,6 +2,9 @@
Meta:
Title: Home
Data:
Image: /schönes_Bild.jpg
Subtitle: und Weiteres
---
# Home

View File

@ -1,8 +1,14 @@
<html>
<meta>
<title>{{ Meta.Title }}</title>
<meta name="description" content="{{ Meta.Description }}" />
<meta name="keywords" content="{{ Meta.Keywords }}" />
</meta>
<body>
{{{ Body }}}
<pre>
{{{ Data }}}
</pre>
</body>
</html>

18
main.go
View File

@ -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))
*/
}