From 2200d995ce654275dde79ecf8985dbc62396aece Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Thu, 14 Aug 2025 17:27:01 +0300 Subject: [PATCH] Reorganize partials Signed-off-by: Nikolaos Karaolidis --- layouts/_default/_markup/render-image.html | 4 +-- layouts/_default/baseof.html | 33 ++----------------- layouts/_default/list.html | 2 +- layouts/_default/single.html | 2 +- layouts/gallery/list.html | 2 +- layouts/partials/{ => components}/footer.html | 0 .../partials/{ => components}/head/bots.html | 0 .../partials/{ => components}/head/css.html | 0 layouts/partials/components/head/index.html | 29 ++++++++++++++++ .../partials/{ => components}/head/js.html | 0 .../{ => components}/head/opengraph.html | 0 layouts/partials/components/head/rss.html | 8 +++++ .../{ => components}/head/twitter.html | 0 layouts/partials/{ => components}/header.html | 0 .../hero/default.html} | 2 +- .../{ => components}/image/index.html | 4 +-- .../{ => components}/image/reflect.html | 12 ++++--- .../partials/{ => components}/list/meta.html | 0 layouts/partials/gallery/hero.html | 0 layouts/partials/gallery/list.html | 2 +- layouts/partials/head/rss.html | 3 -- 21 files changed, 56 insertions(+), 47 deletions(-) rename layouts/partials/{ => components}/footer.html (100%) rename layouts/partials/{ => components}/head/bots.html (100%) rename layouts/partials/{ => components}/head/css.html (100%) create mode 100644 layouts/partials/components/head/index.html rename layouts/partials/{ => components}/head/js.html (100%) rename layouts/partials/{ => components}/head/opengraph.html (100%) create mode 100644 layouts/partials/components/head/rss.html rename layouts/partials/{ => components}/head/twitter.html (100%) rename layouts/partials/{ => components}/header.html (100%) rename layouts/partials/{posts/hero.html => components/hero/default.html} (80%) rename layouts/partials/{ => components}/image/index.html (85%) rename layouts/partials/{ => components}/image/reflect.html (54%) rename layouts/partials/{ => components}/list/meta.html (100%) delete mode 100644 layouts/partials/gallery/hero.html delete mode 100644 layouts/partials/head/rss.html diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 9cf3200..e5f5047 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,5 +1,5 @@ -{{ partial "image/index.html" (dict - "path" .Destination +{{ partial "components/image/index.html" (dict + "src" .Destination "caption" .Text "alt" .Title ) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index e680a69..66c5e4c 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,41 +1,14 @@ - - - + {{ partial "components/head/index.html" . }} - - {{- if .IsHome -}} - {{ .Site.Title }} - {{- else -}} - {{ .Site.Title }} · - {{ .Title }} - {{- end -}} - - - {{ with .Site.Params.description }} - - {{ end }} - - - - - {{ partial "head/bots.html" . }} - {{ partial "head/rss.html" . }} - - {{ partial "head/opengraph.html" . }} - {{ partial "head/twitter.html" . }} - - {{ partial "head/js.html" . }} - {{ partial "head/css.html" . }} - - {{ partial "header.html" . }} + {{ partial "components/header.html" . }} {{ block "main" . }} {{ end }} - {{ partial "footer.html" . }} + {{ partial "components/footer.html" . }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 2053a96..6da67d1 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -2,7 +2,7 @@ {{ $withMeta := default true .Params.withMeta }}
{{ if $withMeta }} - {{ partial "list/meta.html" . }} + {{ partial "components/list/meta.html" . }} {{ end }}
{{ partial "posts/list.html" . }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 8097578..446ae44 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,6 +1,6 @@ {{ define "main" }}
- {{ partial "posts/hero.html" . }} + {{ partial "components/hero/default.html" . }}
{{ .Content }}
diff --git a/layouts/gallery/list.html b/layouts/gallery/list.html index 0045fde..1822e97 100644 --- a/layouts/gallery/list.html +++ b/layouts/gallery/list.html @@ -2,7 +2,7 @@ {{ $withMeta := default true .Params.withMeta }}
{{ if $withMeta }} - {{ partial "list/meta.html" . }} + {{ partial "components/list/meta.html" . }} {{ end }}
{{ partial "gallery/list.html" . }} diff --git a/layouts/partials/footer.html b/layouts/partials/components/footer.html similarity index 100% rename from layouts/partials/footer.html rename to layouts/partials/components/footer.html diff --git a/layouts/partials/head/bots.html b/layouts/partials/components/head/bots.html similarity index 100% rename from layouts/partials/head/bots.html rename to layouts/partials/components/head/bots.html diff --git a/layouts/partials/head/css.html b/layouts/partials/components/head/css.html similarity index 100% rename from layouts/partials/head/css.html rename to layouts/partials/components/head/css.html diff --git a/layouts/partials/components/head/index.html b/layouts/partials/components/head/index.html new file mode 100644 index 0000000..437a957 --- /dev/null +++ b/layouts/partials/components/head/index.html @@ -0,0 +1,29 @@ + + + + + + {{- if .IsHome -}} + {{ .Site.Title }} + {{- else -}} + {{ .Site.Title }} · + {{ .Title }} + {{- end -}} + + + {{ with .Site.Params.description }} + + {{ end }} + + + + + {{ partial "components/head/bots.html" . }} + {{ partial "components/head/rss.html" . }} + + {{ partial "components/head/opengraph.html" . }} + {{ partial "components/head/twitter.html" . }} + + {{ partial "components/head/js.html" . }} + {{ partial "components/head/css.html" . }} + diff --git a/layouts/partials/head/js.html b/layouts/partials/components/head/js.html similarity index 100% rename from layouts/partials/head/js.html rename to layouts/partials/components/head/js.html diff --git a/layouts/partials/head/opengraph.html b/layouts/partials/components/head/opengraph.html similarity index 100% rename from layouts/partials/head/opengraph.html rename to layouts/partials/components/head/opengraph.html diff --git a/layouts/partials/components/head/rss.html b/layouts/partials/components/head/rss.html new file mode 100644 index 0000000..d2756bc --- /dev/null +++ b/layouts/partials/components/head/rss.html @@ -0,0 +1,8 @@ +{{ with .OutputFormats.Get "RSS" }} + +{{ end }} diff --git a/layouts/partials/head/twitter.html b/layouts/partials/components/head/twitter.html similarity index 100% rename from layouts/partials/head/twitter.html rename to layouts/partials/components/head/twitter.html diff --git a/layouts/partials/header.html b/layouts/partials/components/header.html similarity index 100% rename from layouts/partials/header.html rename to layouts/partials/components/header.html diff --git a/layouts/partials/posts/hero.html b/layouts/partials/components/hero/default.html similarity index 80% rename from layouts/partials/posts/hero.html rename to layouts/partials/components/hero/default.html index d74514d..ee9c2fa 100644 --- a/layouts/partials/posts/hero.html +++ b/layouts/partials/components/hero/default.html @@ -5,5 +5,5 @@ · {{ printf "%d MIN READ" .ReadingTime }}
- {{ partial "image/index.html" .Params.hero }} + {{ partial "components/image/index.html" .Params.hero }} diff --git a/layouts/partials/image/index.html b/layouts/partials/components/image/index.html similarity index 85% rename from layouts/partials/image/index.html rename to layouts/partials/components/image/index.html index 1a4efe6..e5683a5 100644 --- a/layouts/partials/image/index.html +++ b/layouts/partials/components/image/index.html @@ -1,4 +1,4 @@ -{{ $imageData := partial "image/reflect.html" . }} +{{ $imageData := partial "components/image/reflect.html" . }} {{- with $imageData.image -}} diff --git a/layouts/partials/image/reflect.html b/layouts/partials/components/image/reflect.html similarity index 54% rename from layouts/partials/image/reflect.html rename to layouts/partials/components/image/reflect.html index d15302a..11d9398 100644 --- a/layouts/partials/image/reflect.html +++ b/layouts/partials/components/image/reflect.html @@ -1,16 +1,18 @@ {{- $input := . -}} {{- $src := $input -}} +{{- $caption := "" -}} {{- $title := "" -}} {{- $alt := "" -}} {{- if reflect.IsMap $input -}} - {{- $src = $input.src | default $input.path | default "" -}} - {{- $title = $input.title | default $input.caption | default "" -}} - {{- $alt = $input.alt | default $title -}} + {{- $src = $input.src | default "" -}} + {{- $caption = $input.caption | default "" -}} + {{- $title = $input.title | default $caption | default "" -}} + {{- $alt = $input.alt | default $title | default "" -}} {{- end -}} -{{ $result := dict "image" nil "title" $title "alt" $alt }} +{{ $result := dict "image" nil "caption" $caption "title" $title "alt" $alt }} {{- if $src -}} {{- $isRemote := strings.HasPrefix $src "http" -}} @@ -23,7 +25,7 @@ {{- $image = resources.Get $src -}} {{- end -}} - {{- $result = (dict "image" $image "title" $title "alt" $alt) -}} + {{- $result = (dict "image" $image "caption" $caption "title" $title "alt" $alt) -}} {{- end -}} {{- return $result -}} diff --git a/layouts/partials/list/meta.html b/layouts/partials/components/list/meta.html similarity index 100% rename from layouts/partials/list/meta.html rename to layouts/partials/components/list/meta.html diff --git a/layouts/partials/gallery/hero.html b/layouts/partials/gallery/hero.html deleted file mode 100644 index e69de29..0000000 diff --git a/layouts/partials/gallery/list.html b/layouts/partials/gallery/list.html index 3deb7d4..cf6eb42 100644 --- a/layouts/partials/gallery/list.html +++ b/layouts/partials/gallery/list.html @@ -2,7 +2,7 @@
{{ range sort .Pages "Date" "desc" }} {{ if not .Params.private }} - {{ $imageData := partial "image/reflect.html" .Params.hero }} + {{ $imageData := partial "components/image/reflect.html" .Params.hero }} {{ with $imageData.image }}