|
|
@ -31,11 +31,13 @@ type Post struct {
|
|
31
|
31
|
}
|
|
32
|
32
|
|
|
33
|
33
|
var flags struct {
|
|
34
|
|
writeBack bool
|
|
35
|
|
hashIds bool
|
|
36
|
|
reverse bool
|
|
37
|
|
css string
|
|
38
|
|
title string
|
|
|
34
|
writeBack bool
|
|
|
35
|
hashIds bool
|
|
|
36
|
reverse bool
|
|
|
37
|
css string
|
|
|
38
|
noDefaultStyle bool
|
|
|
39
|
printDefaultStyle bool
|
|
|
40
|
title string
|
|
39
|
41
|
}
|
|
40
|
42
|
var dataPath string = "blog.yaml"
|
|
41
|
43
|
|
|
|
@ -130,7 +132,9 @@ func init() {
|
|
130
|
132
|
flag.BoolVar(&flags.writeBack, "write-back", false, "Rewrite the YAML file with the generated ids")
|
|
131
|
133
|
flag.BoolVar(&flags.hashIds, "hash-ids", false, "Use hash-based post ids")
|
|
132
|
134
|
flag.BoolVar(&flags.reverse, "reverse", false, "Reverse the order of the articles in the file")
|
|
133
|
|
flag.StringVar(&flags.css, "css", defaultStyle, "Custom `css` styles to use")
|
|
|
135
|
flag.StringVar(&flags.css, "css", "", "Use custom `css` styles")
|
|
|
136
|
flag.BoolVar(&flags.noDefaultStyle, "no-default-style", false, "Don't use the default styles")
|
|
|
137
|
flag.BoolVar(&flags.printDefaultStyle, "print-default-style", false, "Print the default styles")
|
|
134
|
138
|
flag.StringVar(&flags.title, "title", "A blog", "Custom `title` to use")
|
|
135
|
139
|
|
|
136
|
140
|
flag.Usage = func() {
|
|
|
@ -142,6 +146,11 @@ func init() {
|
|
142
|
146
|
func main() {
|
|
143
|
147
|
flag.Parse()
|
|
144
|
148
|
|
|
|
149
|
if flags.printDefaultStyle {
|
|
|
150
|
fmt.Print(defaultStyle)
|
|
|
151
|
os.Exit(0)
|
|
|
152
|
}
|
|
|
153
|
|
|
145
|
154
|
if flag.NArg() > 0 {
|
|
146
|
155
|
dataPath = flag.Arg(0)
|
|
147
|
156
|
}
|
|
|
@ -170,6 +179,9 @@ func main() {
|
|
170
|
179
|
exit(err)
|
|
171
|
180
|
}
|
|
172
|
181
|
|
|
|
182
|
if flags.noDefaultStyle {
|
|
|
183
|
defaultStyle = ""
|
|
|
184
|
}
|
|
173
|
185
|
fmt.Fprintf(out, `<!doctype html>
|
|
174
|
186
|
<html>
|
|
175
|
187
|
<head>
|
|
|
@ -177,10 +189,11 @@ func main() {
|
|
177
|
189
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
178
|
190
|
<title>%s</title>
|
|
179
|
191
|
<style>%s</style>
|
|
|
192
|
<style>%s</style>
|
|
180
|
193
|
</head>
|
|
181
|
194
|
|
|
182
|
195
|
<body>
|
|
183
|
|
`, template.HTMLEscapeString(flags.title), flags.css)
|
|
|
196
|
`, template.HTMLEscapeString(flags.title), defaultStyle, flags.css)
|
|
184
|
197
|
|
|
185
|
198
|
if flags.reverse {
|
|
186
|
199
|
l := len(posts)
|