From bbd3c370dd755cfaac935dc545027c7e736ca86f Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Sat, 20 Nov 2021 14:36:26 +0100 Subject: [PATCH] feat: show post metadata for single posts (#104) --- layouts/_default/list.html | 72 +--------------------------------- layouts/_default/single.html | 26 +++--------- layouts/partials/metadata.html | 71 +++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 91 deletions(-) create mode 100644 layouts/partials/metadata.html diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 90aae1c..4a4d58b 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -21,79 +21,9 @@ {{ end }} {{ partial "pagination.html" . }} {{ end }} - -{{ define "post-tag" }} - - {{ .name }} - -{{ end }} - -{{ define "post-author" }} - - {{ .name }} - -{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 383f163..1f6d56c 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -16,28 +16,14 @@ {{ end }}

{{ partial "title" . }}

- {{ if or (eq .Type (default "posts" .Site.Params.GeekblogContentSection)) (eq .Type "post") }} -
- - - - - - - - - -
- {{ end }} + {{ if or (eq .Type (default "posts" .Site.Params.GeekblogContentSection)) (eq .Type "post") }} +
+ {{ partial "metadata.html" . }} +
+ {{ end }} +
{{ partial "content" . }}
diff --git a/layouts/partials/metadata.html b/layouts/partials/metadata.html new file mode 100644 index 0000000..3fa72a5 --- /dev/null +++ b/layouts/partials/metadata.html @@ -0,0 +1,71 @@ + + + + + + + + + + +{{ if eq .Params.weight 1 }} + + + + +{{ end }} + +{{ $ac := 0 }} +{{ with .Params.authors }} +{{ range sort . }} + {{ $author := index $.Site.Data.authors . }} + {{ with $.Site.GetPage (printf "/authors/%s" . | urlize) }} + {{ if eq $ac 0 }} + + + {{ template "post-author" dict "name" $author.name "page" . }} + + {{ else }} + {{ template "post-author" dict "name" $author.name "page" . }} + {{ end }} + {{ end }} + {{ $ac = (add $ac 1) }} +{{ end }} +{{ end }} + +{{ $tc := 0 }} +{{ with .Params.tags }} +{{ range sort . }} + {{ $name := . }} + {{ with $.Site.GetPage (printf "/tags/%s" $name | urlize) }} + {{ if eq $tc 0 }} + + + {{ template "post-tag" dict "name" $name "page" . }} + + {{ else }} + {{ template "post-tag" dict "name" $name "page" . }} + {{ end }} + {{ end }} + {{ $tc = (add $tc 1) }} +{{ end }} +{{ end }} + +{{ define "post-tag" }} + + {{ .name }} + +{{ end }} + +{{ define "post-author" }} + + {{ .name }} + +{{ end }}