-
Notifications
You must be signed in to change notification settings - Fork 355
/
repo.go
50 lines (40 loc) · 794 Bytes
/
repo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"io/ioutil"
"os"
"os/exec"
"text/template"
gfm "github.com/shurcooL/github_flavored_markdown"
)
// memory usage optimizations
const (
emtyStr = ""
git = "git"
checkout = "checkout"
force = "-f"
pull = "pull"
// options
readmePath = "./README.md"
tplPath = "tmpl/tmpl.html"
idxPath = "tmpl/index.html"
)
var (
doneResp = []byte("Done!\n")
)
type content struct {
Body string
}
func generateHTML() {
// Update repo
exec.Command(git, checkout, force).Output()
exec.Command(git, pull).Output()
input, _ := ioutil.ReadFile(readmePath)
body := string(gfm.Markdown(input))
c := &content{Body: body}
t := template.Must(template.ParseFiles(tplPath))
f, _ := os.Create(idxPath)
t.Execute(f, c)
}
func main() {
generateHTML()
}