Просмотр исходного кода

Add tags metadata to all posts

Lucas Stadler лет назад: 9
Родитель
Сommit
402b9be991
1 измененных файлов с 26 добавлено и 6 удалено
  1. 26 6
      go/blog/blog.go

+ 26 - 6
go/blog/blog.go

348
348
349
var shellTmpl = template.Must(baseTmpl.New("shell").
349
var shellTmpl = template.Must(baseTmpl.New("shell").
350
	Funcs(funcs).Parse(`
350
	Funcs(funcs).Parse(`
351
<article id="{{ .Id }}" class="shell">
351
<article id="{{ .Id }}" class="{{ .Type }}" {{- if .Tags }} data-tags="{{ json .Tags }}"{{ end }}>
352
	<header>
352
	<header>
353
		<h1><code class="language-shell">{{ .Title }}</code></h1>
353
		<h1><code class="language-shell">{{ .Title }}</code></h1>
354
		<a class="permalink" href="#{{ .Id }}">∞</a>
354
		<a class="permalink" href="#{{ .Id }}">∞</a>
359
359
360
	{{ markdown .Content }}
360
	{{ markdown .Content }}
361
	{{- end -}}
361
	{{- end -}}
362
363
	<footer>
364
		{{ template "tags" .Tags }}
365
	</footer>
362
</article>
366
</article>
363
`))
367
`))
364
368
365
var linkTmpl = template.Must(baseTmpl.New("link").
369
var linkTmpl = template.Must(baseTmpl.New("link").
366
	Funcs(funcs).Parse(`
370
	Funcs(funcs).Parse(`
367
<article id="{{ .Id }}" class="link">
371
<article id="{{ .Id }}" class="{{ .Type }}" {{- if .Tags }} data-tags="{{ json .Tags }}"{{ end }}>
368
	<header>
372
	<header>
369
		<h1><a href="{{ .URL }}">{{ .Title }}</a></h1>
373
		<h1><a href="{{ .URL }}">{{ .Title }}</a></h1>
370
		<a class="permalink" href="#{{ .Id }}">∞</a>
374
		<a class="permalink" href="#{{ .Id }}">∞</a>
375
379
376
	{{ markdown .Content }}
380
	{{ markdown .Content }}
377
	{{- end -}}
381
	{{- end -}}
382
383
	<footer>
384
		{{ template "tags" .Tags }}
385
	</footer>
378
</article>
386
</article>
379
`))
387
`))
380
388
381
var imageTmpl = template.Must(baseTmpl.New("image").
389
var imageTmpl = template.Must(baseTmpl.New("image").
382
	Funcs(funcs).Parse(`
390
	Funcs(funcs).Parse(`
383
<article id="{{ .Id }}" class="image">
391
<article id="{{ .Id }}" class="{{ .Type }}" {{- if .Tags }} data-tags="{{ json .Tags }}"{{ end }}>
384
	{{- template "title" . }}
392
	{{- template "title" . }}
385
	<img src="{{ safe_url .URL }}" />
393
	<img src="{{ safe_url .URL }}" />
386
	{{- if .Content }}
394
	{{- if .Content }}
387
395
388
	{{ markdown .Content }}
396
	{{ markdown .Content }}
389
	{{- end -}}
397
	{{- end -}}
398
399
	<footer>
400
		{{ template "tags" .Tags }}
401
	</footer>
390
</article>
402
</article>
391
`))
403
`))
392
404
393
var songTmpl = template.Must(baseTmpl.New("song").
405
var songTmpl = template.Must(baseTmpl.New("song").
394
	Funcs(funcs).Parse(`
406
	Funcs(funcs).Parse(`
395
<article id="{{ .Id }}" class="song">
407
<article id="{{ .Id }}" class="{{ .Type }}" {{- if .Tags }} data-tags="{{ json .Tags }}"{{ end }}>
396
	{{- template "title" . }}
408
	{{- template "title" . }}
397
	<audio src="{{ safe_url .URL }}" controls>
409
	<audio src="{{ safe_url .URL }}" controls>
398
		Your browser can't play {{ .URL }}.
410
		Your browser can't play {{ .URL }}.
401
413
402
	{{ markdown .Content }}
414
	{{ markdown .Content }}
403
	{{- end -}}
415
	{{- end -}}
416
417
	<footer>
418
		{{ template "tags" .Tags }}
419
	</footer>
404
</article>
420
</article>
405
`))
421
`))
406
422
407
var textTmpl = template.Must(baseTmpl.New("text").
423
var textTmpl = template.Must(baseTmpl.New("text").
408
	Funcs(funcs).Parse(`
424
	Funcs(funcs).Parse(`
409
<article id="{{ .Id }}" class="text" {{- if .Tags }} data-tags="{{ json .Tags }}"{{ end }}>
425
<article id="{{ .Id }}" class="{{ .Type }}" {{- if .Tags }} data-tags="{{ json .Tags }}"{{ end }}>
410
	{{- template "title" . }}
426
	{{- template "title" . }}
411
	{{- if .Content }}
427
	{{- if .Content }}
412
428
420
`))
436
`))
421
437
422
var videoTmpl = template.Must(baseTmpl.New("video").Parse(`
438
var videoTmpl = template.Must(baseTmpl.New("video").Parse(`
423
<article id="{{ .Id }}" class="video">
439
<article id="{{ .Id }}" class="{{ .Type }}" {{- if .Tags }} data-tags="{{ json .Tags }}"{{ end }}>
424
	{{- template "title" . }}
440
	{{- template "title" . }}
425
	<iframe width="560" height="315" src="https://www.youtube.com/embed/{{ .URL }}" frameborder="0" allowfullscreen></iframe>
441
	<iframe width="560" height="315" src="https://www.youtube.com/embed/{{ .URL }}" frameborder="0" allowfullscreen></iframe>
426
	{{- if .Content }}
442
	{{- if .Content }}
427
443
428
	{{ markdown .Content }}
444
	{{ markdown .Content }}
429
	{{- end -}}
445
	{{- end -}}
446
447
	<footer>
448
		{{ template "tags" .Tags }}
449
	</footer>
430
</article>
450
</article>
431
`))
451
`))
432
452