Browse Source

add output dir

master
arnaucube 4 years ago
parent
commit
e38e98ce0f
5 changed files with 34 additions and 6 deletions
  1. +2
    -2
      README.md
  2. BIN
      blogo
  3. +9
    -0
      go.mod
  4. +14
    -0
      go.sum
  5. +9
    -4
      main.go

+ 2
- 2
README.md

@ -1,4 +1,4 @@
# Blogo [![Go Report Card](https://goreportcard.com/badge/github.com/arnaucode/blogo)](https://goreportcard.com/report/github.com/arnaucode/blogo)
# Blogo [![Go Report Card](https://goreportcard.com/badge/github.com/arnaucube/blogo)](https://goreportcard.com/report/github.com/arnaucube/blogo)
Static blog generator, templating engine from markdown and html templates
![blogo](https://raw.githubusercontent.com/arnaucube/blogo/master/blogo.png "blogo")
@ -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

BIN
blogo


+ 9
- 0
go.mod

@ -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
- 0
go.sum

@ -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=

+ 9
- 4
main.go

@ -2,17 +2,22 @@ package main
import (
"fmt"
"os"
"strings"
blackfriday "gopkg.in/russross/blackfriday.v2"
// blackfriday "gopkg.in/russross/blackfriday.v2"
"github.com/russross/blackfriday"
)
const directory = "blogo-input"
const outputDir = "public"
func main() {
readConfig(directory + "/blogo.json")
fmt.Println(config)
_ = os.Mkdir(outputDir, os.ModePerm)
// generate index page
indexTemplate := readFile(directory + "/" + config.IndexTemplate)
indexPostTemplate := readFile(directory + "/" + config.PostThumbTemplate)
@ -35,7 +40,7 @@ func main() {
m["[blogo-title]"] = config.Title
m["[blogo-content]"] = blogoIndex
r := putHTMLToTemplate(indexTemplate, m)
writeFile("index.html", r)
writeFile(outputDir+"/"+"index.html", r)
// generate posts pages
@ -54,13 +59,13 @@ func main() {
//fmt.Println(r)
filename := strings.Split(post.Md, ".")[0]
writeFile(filename+".html", r)
writeFile(outputDir+"/"+filename+".html", r)
}
//copy raw
fmt.Println("copying raw:")
for _, dir := range config.CopyRaw {
copyRaw(directory+"/"+dir, ".")
copyRaw(directory+"/"+dir, outputDir+"/")
}
}

Loading…
Cancel
Save