-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
71 lines (53 loc) · 1.26 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
"path/filepath"
"github.com/mpragliola/mate/internal/aggregator"
"github.com/mpragliola/mate/internal/file"
"github.com/mpragliola/mate/internal/mate"
"github.com/mpragliola/mate/internal/postsaver"
"github.com/mpragliola/stopwatch"
)
func main() {
p := mate.NewProject("example", "posts", "layouts", "public", "tags")
pa := mate.NewParser()
ps := &postsaver.FilePostSaver{}
w := mate.NewWriter(ps)
stopwatch := stopwatch.NewStart()
paths, err := aggregator.AggregatePostPaths(p.GetPostsDirectory())
if err != nil {
panic(err)
}
stopwatch.Mark("Aggregate .md")
pages, err := pa.ParsePaths(paths, p)
if err != nil {
panic(err)
}
stopwatch.Mark("Parse to HTML")
err = w.Clean(p)
if err != nil {
panic(err)
}
stopwatch.Mark("Wipe public folder")
err = w.WritePages(pages, p)
if err != nil {
panic(err)
}
stopwatch.Mark("Write HTML - posts")
err = w.WriteTags(pages, p)
if err != nil {
panic(err)
}
stopwatch.Mark("Write HTML - tags")
err = file.Copy(
filepath.Join(p.GetLayoutsDirectory(), "assets"),
filepath.Join(p.GetPublicDirectory(), "assets"),
ps,
)
if err != nil {
panic(err)
}
stopwatch.Mark("Copy assets")
fmt.Printf("No. of posts:%11d posts\n", len(paths))
stopwatch.Dump()
}