|
@ -12,9 +12,9 @@ import ( |
|
|
"github.com/gomarkdown/markdown/parser" |
|
|
"github.com/gomarkdown/markdown/parser" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const version = "v0_20220501" |
|
|
|
|
|
|
|
|
const version = "v0_20220503" |
|
|
const directory = "blogo-input" |
|
|
const directory = "blogo-input" |
|
|
const outputDir = "public" |
|
|
|
|
|
|
|
|
const defaultOutputDir = "public" |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
|
devMode := flag.Bool("d", false, "dev mode") |
|
|
devMode := flag.Bool("d", false, "dev mode") |
|
@ -22,7 +22,8 @@ func main() { |
|
|
flag.Parse() |
|
|
flag.Parse() |
|
|
|
|
|
|
|
|
fmt.Println("Blogo version:", version) |
|
|
fmt.Println("Blogo version:", version) |
|
|
_ = os.Mkdir(outputDir, os.ModePerm) |
|
|
|
|
|
|
|
|
readConfig(directory + "/blogo.json") |
|
|
|
|
|
_ = os.Mkdir(config.OutputDir, os.ModePerm) |
|
|
|
|
|
|
|
|
fmt.Println("devMode:", *devMode) |
|
|
fmt.Println("devMode:", *devMode) |
|
|
generateHTML() |
|
|
generateHTML() |
|
@ -35,7 +36,7 @@ func main() { |
|
|
// go watch("./public")
|
|
|
// go watch("./public")
|
|
|
|
|
|
|
|
|
// serve files
|
|
|
// serve files
|
|
|
fs := http.FileServer(http.Dir("public")) |
|
|
|
|
|
|
|
|
fs := http.FileServer(http.Dir(config.OutputDir)) |
|
|
fmt.Printf("Blog being served in: \n http://127.0.0.1:%s\n http://localhost:%s\n", |
|
|
fmt.Printf("Blog being served in: \n http://127.0.0.1:%s\n http://localhost:%s\n", |
|
|
*port, *port) |
|
|
*port, *port) |
|
|
log.Fatal(http.ListenAndServe(":"+*port, fs)) |
|
|
log.Fatal(http.ListenAndServe(":"+*port, fs)) |
|
@ -75,7 +76,7 @@ func generateHTML() { |
|
|
m["[blogo-img]"] = config.AbsoluteUrl + "/" + config.MetaImg |
|
|
m["[blogo-img]"] = config.AbsoluteUrl + "/" + config.MetaImg |
|
|
m["[blogo-link]"] = config.AbsoluteUrl |
|
|
m["[blogo-link]"] = config.AbsoluteUrl |
|
|
r := putHTMLToTemplate(indexTemplate, m) |
|
|
r := putHTMLToTemplate(indexTemplate, m) |
|
|
writeFile(outputDir+"/"+"index.html", r) |
|
|
|
|
|
|
|
|
writeFile(config.OutputDir+"/"+"index.html", r) |
|
|
|
|
|
|
|
|
// generate posts pages
|
|
|
// generate posts pages
|
|
|
|
|
|
|
|
@ -97,13 +98,13 @@ func generateHTML() { |
|
|
m["[blogo-img]"] = config.AbsoluteUrl + "/" + post.MetaImg |
|
|
m["[blogo-img]"] = config.AbsoluteUrl + "/" + post.MetaImg |
|
|
|
|
|
|
|
|
r := putHTMLToTemplate(indexTemplate, m) |
|
|
r := putHTMLToTemplate(indexTemplate, m) |
|
|
writeFile(outputDir+"/"+filename+".html", r) |
|
|
|
|
|
|
|
|
writeFile(config.OutputDir+"/"+filename+".html", r) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//copy raw
|
|
|
//copy raw
|
|
|
fmt.Println("copying raw:") |
|
|
fmt.Println("copying raw:") |
|
|
for _, dir := range config.CopyRaw { |
|
|
for _, dir := range config.CopyRaw { |
|
|
copyRaw(directory+"/"+dir, outputDir+"/") |
|
|
|
|
|
|
|
|
copyRaw(directory+"/"+dir, config.OutputDir+"/") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|