浏览代码

Add a flag to change the CSS

Lucas Stadler 9 年之前
父节点
当前提交
4b16cc1743
共有 1 个文件被更改,包括 20 次插入16 次删除
  1. 20 16
      go/blog/blog.go

+ 20 - 16
go/blog/blog.go

@ -27,12 +27,30 @@ type Post struct {
27 27
var flags struct {
28 28
	writeBack bool
29 29
	reverse   bool
30
	css       string
30 31
}
31 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 50
func init() {
34 51
	flag.BoolVar(&flags.writeBack, "write-back", false, "Rewrite the YAML file with the generated ids")
35 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 56
func main() {
@ -63,25 +81,11 @@ func main() {
63 81
<head>
64 82
	<meta charset="utf-8" />
65 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 85
</head>
82 86
83 87
<body>
84
`)
88
`, flags.css)
85 89
86 90
	if flags.reverse {
87 91
		l := len(posts)