Lucas Stadler лет назад: 9
Родитель
Сommit
4b16cc1743
1 измененных файлов с 20 добавлено и 16 удалено
  1. 20 16
      go/blog/blog.go

+ 20 - 16
go/blog/blog.go

27
var flags struct {
27
var flags struct {
28
	writeBack bool
28
	writeBack bool
29
	reverse   bool
29
	reverse   bool
30
	css       string
30
}
31
}
31
var dataPath string = "blog.yaml"
32
var dataPath string = "blog.yaml"
32
33
34
var defaultStyle = `
35
article header {
36
	display: flex;
37
	align-items: center;
38
}
39
40
article h1 {
41
	margin: 0;
42
	margin-right: 1em;
43
}
44
45
article time {
46
	color: #666;
47
}
48
`
49
33
func init() {
50
func init() {
34
	flag.BoolVar(&flags.writeBack, "write-back", false, "Rewrite the YAML file with the generated ids")
51
	flag.BoolVar(&flags.writeBack, "write-back", false, "Rewrite the YAML file with the generated ids")
35
	flag.BoolVar(&flags.reverse, "reverse", false, "Reverse the order of the articles in the file")
52
	flag.BoolVar(&flags.reverse, "reverse", false, "Reverse the order of the articles in the file")
53
	flag.StringVar(&flags.css, "css", defaultStyle, "Custom styles to use")
36
}
54
}
37
55
38
func main() {
56
func main() {
63
<head>
81
<head>
64
	<meta charset="utf-8" />
82
	<meta charset="utf-8" />
65
	<title>A blog</title>
83
	<title>A blog</title>
66
	<style>
67
		article header {
68
			display: flex;
69
			align-items: center;
70
		}
71
72
		article h1 {
73
			margin: 0;
74
			margin-right: 1em;
75
		}
76
77
		article time {
78
			color: #666;
79
		}
80
	</style>
84
	<style>%s</style>
81
</head>
85
</head>
82
86
83
<body>
87
<body>
84
`)
88
`, flags.css)
85
89
86
	if flags.reverse {
90
	if flags.reverse {
87
		l := len(posts)
91
		l := len(posts)