mirror of
https://github.com/arnaucube/blogo.git
synced 2026-02-07 11:56:40 +01:00
add metatags
This commit is contained in:
24
README.md
24
README.md
@@ -6,6 +6,30 @@ Static blog generator, templating engine from markdown and html templates
|
|||||||
## Use
|
## Use
|
||||||
A complete usage example can be found in this repo: https://github.com/arnaucube/blogoExample
|
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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -51,14 +51,16 @@ func main() {
|
|||||||
firstline := strings.Split(mdcontent, "\n")[0]
|
firstline := strings.Split(mdcontent, "\n")[0]
|
||||||
title := strings.Replace(firstline, "# ", "", -1)
|
title := strings.Replace(firstline, "# ", "", -1)
|
||||||
|
|
||||||
|
filename := strings.Split(post.Md, ".")[0]
|
||||||
|
|
||||||
m := make(map[string]string)
|
m := make(map[string]string)
|
||||||
m["[blogo-title]"] = title + " - " + config.Title
|
m["[blogo-title]"] = title + " - " + config.Title
|
||||||
m["[blogo-content]"] = htmlcontent
|
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)
|
r := putHTMLToTemplate(indexTemplate, m)
|
||||||
//fmt.Println(r)
|
|
||||||
|
|
||||||
filename := strings.Split(post.Md, ".")[0]
|
|
||||||
writeFile(outputDir+"/"+filename+".html", r)
|
writeFile(outputDir+"/"+filename+".html", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,15 @@ import (
|
|||||||
type Post struct {
|
type Post struct {
|
||||||
Thumb string `json:"thumb"`
|
Thumb string `json:"thumb"`
|
||||||
Md string `json:"md"`
|
Md string `json:"md"`
|
||||||
|
MetaImg string `json:"metaimg"`
|
||||||
|
MetaDescr string `json:"metadescr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//Config gets the config.json file into struct
|
//Config gets the config.json file into struct
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
RelativePath string `json:"relativePath"`
|
RelativePath string `json:"relativePath"`
|
||||||
|
AbsoluteUrl string `json:"absoluteUrl"`
|
||||||
IndexTemplate string `json:"indexTemplate"`
|
IndexTemplate string `json:"indexTemplate"`
|
||||||
PostThumbTemplate string `json:"postThumbTemplate"`
|
PostThumbTemplate string `json:"postThumbTemplate"`
|
||||||
Posts []Post `json:"posts"`
|
Posts []Post `json:"posts"`
|
||||||
|
|||||||
Reference in New Issue
Block a user