arnaucube
arnaucube/blogoPublic Self-hosted repository
add metatags
arnaucube root@arnaucube.com
Mon, 27 Jan 2020 10:53:29 +0100
commit

c2f0df4756e5565f649a6ddea7c98f4eca9b37bc

parent

e38e98ce0fa3e2796884e810fdc353bab91f99cf

4 files changed, 34 insertions(+), 5 deletions(-)

jump to
M README.md → README.md

@@ -6,6 +6,30 @@

## Use A complete usage example can be found in this repo: https://github.com/arnaucube/blogoExample +### Config example +```json +{ + "title": "Blogo Blog", + "relativePath": "", + "absoluteUrl": "https://blog.website.com", + "indexTemplate": "index.html", + "postThumbTemplate": "postThumbTemplate.html", + "posts": [ + { + "thumb": "article0_thumb.md", + "md": "article0.md", + "metaimg": "img/article0-img.png", + "metadescr": "description of the article 0" + }, + ], + "copyRaw": [ + "css", + "img", + "js" + ] +} +``` + ---
M main.go → main.go

@@ -51,14 +51,16 @@

firstline := strings.Split(mdcontent, "\n")[0] title := strings.Replace(firstline, "# ", "", -1) + filename := strings.Split(post.Md, ".")[0] + m := make(map[string]string) m["[blogo-title]"] = title + " - " + config.Title m["[blogo-content]"] = htmlcontent + m["[blogo-summary]"] = post.MetaDescr + m["[blogo-link]"] = config.AbsoluteUrl + "/" + filename + ".html" + m["[blogo-img]"] = config.AbsoluteUrl + "/" + post.MetaImg r := putHTMLToTemplate(indexTemplate, m) - //fmt.Println(r) - - filename := strings.Split(post.Md, ".")[0] writeFile(outputDir+"/"+filename+".html", r) }
M readConfig.go → readConfig.go

@@ -7,14 +7,17 @@ )

//Post is the struct for each post of the blog type Post struct { - Thumb string `json:"thumb"` - Md string `json:"md"` + Thumb string `json:"thumb"` + Md string `json:"md"` + MetaImg string `json:"metaimg"` + MetaDescr string `json:"metadescr"` } //Config gets the config.json file into struct type Config struct { Title string `json:"title"` RelativePath string `json:"relativePath"` + AbsoluteUrl string `json:"absoluteUrl"` IndexTemplate string `json:"indexTemplate"` PostThumbTemplate string `json:"postThumbTemplate"` Posts []Post `json:"posts"`