Przeglądaj źródła

Add an optional date field

Lucas Stadler 9 lat temu
rodzic
commit
7b2b2cde49
2 zmienionych plików z 11 dodań i 2 usunięć
  1. 9 2
      go/blog/blog.go
  2. 2 0
      go/blog/blog.yaml

+ 9 - 2
go/blog/blog.go

@ -20,6 +20,7 @@ type Post struct {
20 20
	Title   string `yaml:"title"`
21 21
	URL     string `yaml:"url"`
22 22
	Content string `yaml:"content"`
23
	Date    string `yaml:"date"`
23 24
	Type    string `yaml:"type"`
24 25
}
25 26
@ -117,7 +118,10 @@ var funcs = template.FuncMap{
117 118
var shellTmpl = template.Must(template.New("shell").
118 119
	Funcs(funcs).Parse(`
119 120
<article id="{{ .Id }}" class="shell">
120
	<h1><code class="language-shell">{{ .Title }}</code></h1>
121
	<header>
122
		<h1><code class="language-shell">{{ .Title }}</code></h1>
123
		{{- if .Date }}<time>{{ .Date }}</time>{{ end -}}
124
	</header>
121 125
	{{- if .Content }}
122 126
123 127
	{{ markdown .Content }}
@ -128,7 +132,10 @@ var shellTmpl = template.Must(template.New("shell").
128 132
var linkTmpl = template.Must(template.New("link").
129 133
	Funcs(funcs).Parse(`
130 134
<article id="{{ .Id }}" class="link">
131
	<h1><a href="{{ .URL }}">{{ .Title }}</a></h1>
135
	<header>
136
		<h1><a href="{{ .URL }}">{{ .Title }}</a></h1>
137
		{{- if .Date }}<time>{{ .Date }}</time>{{ end -}}
138
	</header>
132 139
	{{- if .Content }}
133 140
134 141
	{{ markdown .Content }}

+ 2 - 0
go/blog/blog.yaml

@ -4,8 +4,10 @@
4 4
    Find infrequently used binaries on your system.  `ls --time=atime`
5 5
    is the key here, it uses the access time instead of the modification
6 6
    time, which is the default.
7
  date: "2016-09-20"
7 8
  type: shell
8 9
- title: XOXO Festival videos (2012-2015)
9 10
  url: https://www.youtube.com/user/xoxofest/videos
10 11
  content: Unfortunately, the ones for 2016 are missing.  I'm not sure if there will be video, I haven't found anything official so far.
12
  date: "2016-09-24"
11 13
  type: link