mirror of
https://github.com/arnaucube/blogo.git
synced 2026-02-07 03:46:40 +01:00
add output dir
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Blogo [](https://goreportcard.com/report/github.com/arnaucode/blogo)
|
# Blogo [](https://goreportcard.com/report/github.com/arnaucube/blogo)
|
||||||
Static blog generator, templating engine from markdown and html templates
|
Static blog generator, templating engine from markdown and html templates
|
||||||
|
|
||||||

|

|
||||||
@@ -9,4 +9,4 @@ A complete usage example can be found in this repo: https://github.com/arnaucube
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Blogo is used in https://arnaucode.com/blog
|
Blogo is used in https://arnaucube.com/blog
|
||||||
|
|||||||
9
go.mod
Normal file
9
go.mod
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
module github.com/arnaucube/blogo
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/fatih/color v1.9.0
|
||||||
|
github.com/russross/blackfriday v2.0.0+incompatible
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||||
|
)
|
||||||
14
go.sum
Normal file
14
go.sum
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
|
||||||
|
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||||
|
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
|
||||||
|
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
|
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
|
||||||
|
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||||
|
github.com/russross/blackfriday v2.0.0+incompatible h1:cBXrhZNUf9C+La9/YpS+UHpUT8YD6Td9ZMSU9APFcsk=
|
||||||
|
github.com/russross/blackfriday v2.0.0+incompatible/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
13
main.go
13
main.go
@@ -2,17 +2,22 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
blackfriday "gopkg.in/russross/blackfriday.v2"
|
// blackfriday "gopkg.in/russross/blackfriday.v2"
|
||||||
|
"github.com/russross/blackfriday"
|
||||||
)
|
)
|
||||||
|
|
||||||
const directory = "blogo-input"
|
const directory = "blogo-input"
|
||||||
|
const outputDir = "public"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
readConfig(directory + "/blogo.json")
|
readConfig(directory + "/blogo.json")
|
||||||
fmt.Println(config)
|
fmt.Println(config)
|
||||||
|
|
||||||
|
_ = os.Mkdir(outputDir, os.ModePerm)
|
||||||
|
|
||||||
// generate index page
|
// generate index page
|
||||||
indexTemplate := readFile(directory + "/" + config.IndexTemplate)
|
indexTemplate := readFile(directory + "/" + config.IndexTemplate)
|
||||||
indexPostTemplate := readFile(directory + "/" + config.PostThumbTemplate)
|
indexPostTemplate := readFile(directory + "/" + config.PostThumbTemplate)
|
||||||
@@ -35,7 +40,7 @@ func main() {
|
|||||||
m["[blogo-title]"] = config.Title
|
m["[blogo-title]"] = config.Title
|
||||||
m["[blogo-content]"] = blogoIndex
|
m["[blogo-content]"] = blogoIndex
|
||||||
r := putHTMLToTemplate(indexTemplate, m)
|
r := putHTMLToTemplate(indexTemplate, m)
|
||||||
writeFile("index.html", r)
|
writeFile(outputDir+"/"+"index.html", r)
|
||||||
|
|
||||||
// generate posts pages
|
// generate posts pages
|
||||||
|
|
||||||
@@ -54,13 +59,13 @@ func main() {
|
|||||||
//fmt.Println(r)
|
//fmt.Println(r)
|
||||||
|
|
||||||
filename := strings.Split(post.Md, ".")[0]
|
filename := strings.Split(post.Md, ".")[0]
|
||||||
writeFile(filename+".html", r)
|
writeFile(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, ".")
|
copyRaw(directory+"/"+dir, outputDir+"/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user