Bladeren bron

Add tags metadata to all posts

Lucas Stadler 9 jaren geleden
bovenliggende
commit
402b9be991
1 gewijzigde bestanden met toevoegingen van 26 en 6 verwijderingen
  1. 26 6
      go/blog/blog.go

+ 26 - 6
go/blog/blog.go

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