From 1938167450c7cb990c13f1ba40ea5fea2ddefd40 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Mon, 20 Mar 2023 16:37:04 -0400 Subject: [PATCH] tune theme to re-use more code ; setup fundamentals for content on branch folders --- themes/hugo-xmin/layouts/_default/list.html | 7 +++- themes/hugo-xmin/layouts/_default/single.html | 41 +------------------ .../hugo-xmin/layouts/partials/page_meta.html | 29 +++++++++++++ .../hugo-xmin/layouts/partials/related.html | 11 +++++ 4 files changed, 47 insertions(+), 41 deletions(-) create mode 100644 themes/hugo-xmin/layouts/partials/page_meta.html create mode 100644 themes/hugo-xmin/layouts/partials/related.html diff --git a/themes/hugo-xmin/layouts/_default/list.html b/themes/hugo-xmin/layouts/_default/list.html index 5c7f8d8..0978b54 100644 --- a/themes/hugo-xmin/layouts/_default/list.html +++ b/themes/hugo-xmin/layouts/_default/list.html @@ -1,14 +1,18 @@ {{ partial "header.html" . }} +{{ if not .Params.isBranchWithContent }} {{if not .IsHome }}

{{ .Title | markdownify }}

{{ end }} +{{ else }} +{{ partial "page_meta.html" .}} +{{ end }} {{ .Content }} +{{ if not .Params.isBranchWithContent }} {{ if not .IsHome }} {{ template "_internal/pagination.html" . }} {{ end }} +{{ end }} {{ partial "footer.html" . }} diff --git a/themes/hugo-xmin/layouts/_default/single.html b/themes/hugo-xmin/layouts/_default/single.html index 508bb46..228da00 100644 --- a/themes/hugo-xmin/layouts/_default/single.html +++ b/themes/hugo-xmin/layouts/_default/single.html @@ -1,48 +1,9 @@ {{ partial "header.html" . }} -
-

{{ .Title | markdownify }}

-{{ with .Params.author }} -

By: - {{ if (reflect.IsSlice .) }} - {{ delimit . ", " }} - {{ else }} - {{ . }} - {{ end }} -

-{{ end }} -{{ if (gt .Date 0) }}

Published: {{ .Date.Format "2006/01/02" }}

{{ end }} -{{ if (gt .Lastmod 0) }}

Last Modified: {{ .Lastmod.Format "2006/01/02" }}

{{ end }} -

- {{ range $i := (slice "categories" "tags") }} - {{ with ($.Param $i) }} - {{ $i | title }}: {{ range $k := . }}{{$k}} {{ end }} - {{ end }} - {{ end }} -

-
- -{{ if .Params.toc }} -{{ .TableOfContents }} -{{ end }} +{{ partial "page_meta.html" .}}
{{ .Content }}
-{{ range first 1 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }} - {{ $.Scratch.Set "has_related" true }} -{{ end }} - -{{ if $.Scratch.Get "has_related" }} -

See Also

- - Back to top -{{ end }} - {{ partial "footer.html" . }} diff --git a/themes/hugo-xmin/layouts/partials/page_meta.html b/themes/hugo-xmin/layouts/partials/page_meta.html new file mode 100644 index 0000000..54d318e --- /dev/null +++ b/themes/hugo-xmin/layouts/partials/page_meta.html @@ -0,0 +1,29 @@ +
+

{{ .Title | markdownify }}

+ {{ with .Params.author }} +

By: + {{ if (reflect.IsSlice .) }} + {{ delimit . ", " }} + {{ else }} + {{ . }} + {{ end }} +

+ {{ end }} + + {{ if (gt .Date 0) }}

Published: {{ .Date.Format "2006/01/02" }}

{{ end }} + {{ if (gt .Lastmod 0) }}

Last Modified: {{ .Lastmod.Format "2006/01/02" }}

{{ end }} +

+ {{ range $i := (slice "categories" "tags") }} + {{ with ($.Param $i) }} + {{ $i | title }}: {{ range $k := . }}{{$k}} {{ end }} + {{ end }} + {{ end }} +

+

+ {{ partial "related.html" . }} +

+
+ + {{ if .Params.toc }} + {{ .TableOfContents }} + {{ end }} \ No newline at end of file diff --git a/themes/hugo-xmin/layouts/partials/related.html b/themes/hugo-xmin/layouts/partials/related.html new file mode 100644 index 0000000..2a3a67c --- /dev/null +++ b/themes/hugo-xmin/layouts/partials/related.html @@ -0,0 +1,11 @@ +{{ range first 1 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }} + {{ $.Scratch.Set "has_related" true }} +{{ end }} + +{{ if $.Scratch.Get "has_related" }} + Related Pages: + {{ $num_to_show := .Site.Params.related_content_limit | default 5 }} + {{ range first $num_to_show (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }} + {{ .Title }} + {{ end }} +{{ end }} \ No newline at end of file