From f7fbd1e7f2f9be08ecca064d247a8cb74db41c7a Mon Sep 17 00:00:00 2001 From: Frieder Schrempf Date: Mon, 28 Dec 2020 11:14:39 +0100 Subject: [PATCH 1/3] Move author and date information for post to common partials To remove code duplication, let's move this to a partial and reuse it. --- layouts/micro/single.html | 3 +-- layouts/micro/summary.html | 3 +-- layouts/partials/author-date.html | 2 ++ layouts/partials/submitted.html | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 layouts/partials/author-date.html diff --git a/layouts/micro/single.html b/layouts/micro/single.html index 20f180c..c8731e0 100644 --- a/layouts/micro/single.html +++ b/layouts/micro/single.html @@ -4,8 +4,7 @@

{{ .Title }}

-{{ with $.Param "author" }}{{ . }} – {{ end -}} - +{{ partial "author-date" . }}

diff --git a/layouts/micro/summary.html b/layouts/micro/summary.html index 6acdab4..28aa9d5 100644 --- a/layouts/micro/summary.html +++ b/layouts/micro/summary.html @@ -2,8 +2,7 @@

-{{ with $.Param "author" }}{{ . }} – {{ end -}} - +{{ partial "author-date" . }}

diff --git a/layouts/partials/author-date.html b/layouts/partials/author-date.html new file mode 100644 index 0000000..10fa659 --- /dev/null +++ b/layouts/partials/author-date.html @@ -0,0 +1,2 @@ +{{ with $.Param "author" }} – {{ end -}} + \ No newline at end of file diff --git a/layouts/partials/submitted.html b/layouts/partials/submitted.html index 55ff27c..b41bf73 100644 --- a/layouts/partials/submitted.html +++ b/layouts/partials/submitted.html @@ -1,4 +1,3 @@ From 4633d080179388944a281abd05daa8af5aa55101 Mon Sep 17 00:00:00 2001 From: Frieder Schrempf Date: Mon, 28 Dec 2020 11:17:43 +0100 Subject: [PATCH 2/3] Don't show date information of post when no date is set --- layouts/partials/author-date.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/layouts/partials/author-date.html b/layouts/partials/author-date.html index 10fa659..fd51344 100644 --- a/layouts/partials/author-date.html +++ b/layouts/partials/author-date.html @@ -1,2 +1,3 @@ -{{ with $.Param "author" }} – {{ end -}} - \ No newline at end of file +{{ with .Param "author" }}{{ end -}} +{{ if and .Date (.Param "author") }} - {{ end -}} +{{ with .Date }}{{ end }} \ No newline at end of file From 2c65850e1a66fb78432800d043e38dbf1b1a4ffc Mon Sep 17 00:00:00 2001 From: Frieder Schrempf Date: Tue, 29 Dec 2020 10:13:05 +0100 Subject: [PATCH 3/3] fixup! Don't show date information of post when no date is set --- layouts/partials/author-date.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/author-date.html b/layouts/partials/author-date.html index fd51344..f6355a7 100644 --- a/layouts/partials/author-date.html +++ b/layouts/partials/author-date.html @@ -1,3 +1,3 @@ -{{ with .Param "author" }}{{ end -}} -{{ if and .Date (.Param "author") }} - {{ end -}} +{{ with $.Param "author" }}{{ end -}} +{{ if and .Date ($.Param "author") }} - {{ end -}} {{ with .Date }}{{ end }} \ No newline at end of file