mirror of
https://github.com/arnaucube/blogo.git
synced 2026-02-06 19:36:39 +01:00
Add OutsideArticle option
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
9
main.go
9
main.go
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/gomarkdown/markdown/parser"
|
"github.com/gomarkdown/markdown/parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "v0_20220514"
|
const version = "v0_20221124"
|
||||||
const directory = "blogo-input"
|
const directory = "blogo-input"
|
||||||
const defaultOutputDir = "public"
|
const defaultOutputDir = "public"
|
||||||
|
|
||||||
@@ -65,8 +65,12 @@ func generateHTML() {
|
|||||||
m := make(map[string]string)
|
m := make(map[string]string)
|
||||||
m["[blogo-index-post-template]"] = string(htmlpostthumb)
|
m["[blogo-index-post-template]"] = string(htmlpostthumb)
|
||||||
r := putHTMLToTemplate(indexPostTemplate, m)
|
r := putHTMLToTemplate(indexPostTemplate, m)
|
||||||
|
if post.OutsideArticle != "" {
|
||||||
|
r = "<a href='" + post.OutsideArticle + "'>" + r + "</a>"
|
||||||
|
} else {
|
||||||
filename := strings.Split(post.Md, ".")[0]
|
filename := strings.Split(post.Md, ".")[0]
|
||||||
r = "<a href='" + config.RelativePath + "/" + filename + ".html'>" + r + "</a>"
|
r = "<a href='" + config.RelativePath + "/" + filename + ".html'>" + r + "</a>"
|
||||||
|
}
|
||||||
blogoIndex = blogoIndex + r
|
blogoIndex = blogoIndex + r
|
||||||
}
|
}
|
||||||
//put the blogoIndex in the index.html
|
//put the blogoIndex in the index.html
|
||||||
@@ -82,6 +86,9 @@ func generateHTML() {
|
|||||||
// generate posts pages
|
// generate posts pages
|
||||||
|
|
||||||
for _, post := range config.Posts {
|
for _, post := range config.Posts {
|
||||||
|
if post.OutsideArticle != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
mdcontent := readFile(directory + "/" + config.PostsDir + post.Md)
|
mdcontent := readFile(directory + "/" + config.PostsDir + post.Md)
|
||||||
mdParser := parser.NewWithExtensions(mdExtensions)
|
mdParser := parser.NewWithExtensions(mdExtensions)
|
||||||
htmlcontent := markdown.ToHTML([]byte(mdcontent), mdParser, nil)
|
htmlcontent := markdown.ToHTML([]byte(mdcontent), mdParser, nil)
|
||||||
|
|||||||
@@ -5,15 +5,16 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
//Post is the struct for each post of the blog
|
// Post is the struct for each post of the blog
|
||||||
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"`
|
MetaImg string `json:"metaimg"`
|
||||||
MetaDescr string `json:"metadescr"`
|
MetaDescr string `json:"metadescr"`
|
||||||
|
OutsideArticle string `json:"outsideArticle"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//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"`
|
||||||
MetaImg string `json:"metaimg"`
|
MetaImg string `json:"metaimg"`
|
||||||
|
|||||||
Reference in New Issue
Block a user