From 3f7f37851c5482b06a89456b80710cf39382b042 Mon Sep 17 00:00:00 2001 From: Dionysis Grigoropoulos Date: Thu, 26 May 2016 00:44:09 +0300 Subject: Create a partial template for the header of posts * Move duplicate code that handles the header/title of a post in a partial template. * Format code a bit. --- layouts/index.html | 16 ++-------------- layouts/partials/post_header.html | 18 ++++++++++++++++++ layouts/post/single.html | 12 +----------- 3 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 layouts/partials/post_header.html diff --git a/layouts/index.html b/layouts/index.html index 0598df7..c44ebf9 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -6,20 +6,8 @@ {{ $paginator := .Paginate (where .Data.Pages "Type" "post") }} {{ range $paginator.Pages }}
-
-

- {{ .Title }} -

-

{{ .Date.Format "Jan 2, 2006" }} - {{ .ReadingTime }} minute read - {{ if .Site.Params.disqusShortname }} Comments{{ end }} - {{ if isset .Params "categories" }} - - - {{ range .Params.categories }}{{ . }}{{ end }} - {{ end }}

- -
+ {{ partial "post_header.html" . }} {{ if eq .Site.Params.truncate false }} {{ .Content }} @@ -50,4 +38,4 @@ -{{ partial "footer.html" . }} \ No newline at end of file +{{ partial "footer.html" . }} diff --git a/layouts/partials/post_header.html b/layouts/partials/post_header.html new file mode 100644 index 0000000..3868f4f --- /dev/null +++ b/layouts/partials/post_header.html @@ -0,0 +1,18 @@ + + +
+

+ {{ if .IsHome }} {{ .Title }} {{ else }} {{ .Title }} {{ end }} +

+

{{ .Date.Format "Jan 2, 2006" }} + - {{ .ReadingTime }} minute read + {{ if .Site.Params.disqusShortname }} - Comments{{ end }} + + {{ if isset .Params "categories" }} + + + - {{ range .Params.categories }}{{ . }}{{ end }} + {{ end }} +

+
diff --git a/layouts/post/single.html b/layouts/post/single.html index 2e843f3..d61ba0d 100644 --- a/layouts/post/single.html +++ b/layouts/post/single.html @@ -4,19 +4,9 @@
-
-

- {{ .Title }} -

-

{{ .Date.Format "Jan 2, 2006" }} - {{ .ReadingTime }} minute read - {{ if .Site.Params.disqusShortname }} Comments{{ end }} - + {{ partial "post_header.html" . }} - {{ if isset .Params "categories" }} - - {{ range .Params.categories }}{{ . }}{{ end }} - {{ end }}

-
{{ $.Scratch.Set "pagetoc" .TableOfContents }} -- cgit v1.2.3