|
@ -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+"/") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|