From 34257459124be27d3d81037363504884bce435cd Mon Sep 17 00:00:00 2001 From: mtvnnb Date: Sat, 15 Mar 2025 13:10:10 +0700 Subject: [PATCH] update home page layout, remove author image --- layouts/index.html | 2 +- .../partials/sections/home_coexistspace.html | 202 ++++++++++++++++++ 2 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/sections/home_coexistspace.html diff --git a/layouts/index.html b/layouts/index.html index cd8afbc..840dda4 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -29,7 +29,7 @@ {{- partial "navigators/navbar.html" . -}} - {{- partial "sections/home.html" . -}} + {{- partial "sections/home_coexistspace.html" . -}} {{ $sections:= site.Data.sections }} diff --git a/layouts/partials/sections/home_coexistspace.html b/layouts/partials/sections/home_coexistspace.html new file mode 100644 index 0000000..61dc3b7 --- /dev/null +++ b/layouts/partials/sections/home_coexistspace.html @@ -0,0 +1,202 @@ +{{ $author:= site.Data.author }} +{{ if (index site.Data site.Language.Lang).author }} + {{ $author = (index site.Data site.Language.Lang).author }} +{{ end }} + +{{ $name:="Jane Doe" }} +{{ if $author.nickname }} + {{ $name = $author.nickname }} +{{ else if $author.name }} + {{ $name = $author.name }} +{{ end }} + +{{ $sections:= site.Data.sections }} +{{ if (index site.Data site.Language.Lang).sections }} + {{ $sections = (index site.Data site.Language.Lang).sections }} +{{ end }} + +{{ $backgroundImage:= "/images/default-background.jpg" }} +{{ if site.Params.background }} + {{ $backgroundImage = site.Params.background }} +{{ end }} + +{{ $darkBackgroundImage:= $backgroundImage }} +{{ if site.Params.darkBackground }} + {{ $darkBackgroundImage = site.Params.darkBackground }} +{{ end }} + +{{ $authorImage:= "/images/default-avatar.png" }} +{{ if $author.image }} + {{ $authorImage = $author.image }} +{{ end }} +{{ $authorImage := resources.Get $authorImage }} + +{{/* apply image processing. don't use "Fit" in svg or gif because its not supported */}} +{{ if and $authorImage (and (ne $authorImage.MediaType.SubType "svg") ( ne $authorImage.MediaType.SubType "gif")) }} + {{ $authorImage = $authorImage.Fit "148x148" }} +{{ end }} +{{/* get file that matches the filename as specified as src="" in shortcode */}} +{{ $src := resources.Get $backgroundImage }} + +{{/* set image sizes, these are hardcoded for now, x dictates that images are resized to this width */}} + +{{ $tinyw := default "500x" }} +{{ $smallw := default "800x" }} +{{ $mediumw := default "1200x" }} +{{ $largew := default "1500x" }} + +{{/* resize the src image to the given sizes */}} + +{{ $tiny := $src.Resize $tinyw }} +{{ $small := $src.Resize $smallw }} +{{ $medium := $src.Resize $mediumw }} +{{ $large := $src.Resize $largew }} + +{{/* only use images smaller than or equal to the src (original) image size, as Hugo will upscale small images */}} +{{/* set the sizes attribute to (min-width: 35em) 1200px, 100vw unless overridden in shortcode */}} + +{{ if lt $src.Width "500" }} + {{ $tiny := $src}} + {{ $small := $src}} + {{ $medium := $src}} + {{ $large := $src}} +{{ end }} + +{{ if lt $src.Width "800" }} + {{ $small := $src}} + {{ $medium := $src}} + {{ $large := $src}} +{{ end }} + +{{ if lt $src.Width "1200" }} + {{ $medium := $src}} + {{ $large := $src}} +{{ end }} + +{{ if lt $src.Width "1500" }} + {{ $large := $src}} +{{ end }} + +{{/* get file that matches the filename as specified as src="" in shortcode */}} +{{ $darkSrc := resources.Get $darkBackgroundImage }} + +{{/* resize the src image to the given sizes */}} + +{{ $darkTiny := $darkSrc.Resize $tinyw }} +{{ $darkSmall := $darkSrc.Resize $smallw }} +{{ $darkMedium := $darkSrc.Resize $mediumw }} +{{ $darkLarge := $darkSrc.Resize $largew }} + +{{/* only use images smaller than or equal to the src (original) image size, as Hugo will upscale small images */}} +{{/* set the sizes attribute to (min-width: 35em) 1200px, 100vw unless overridden in shortcode */}} + +{{ if lt $darkSrc.Width "500" }} + {{ $darkTiny := $src}} + {{ $darkSmall := $src}} + {{ $darkMedium := $src}} + {{ $darkLarge := $src}} +{{ end }} + +{{ if lt $src.Width "800" }} + {{ $darkSmall := $src}} + {{ $darkMedium := $src}} + {{ $darkLarge := $src}} +{{ end }} + +{{ if lt $src.Width "1200" }} + {{ $darkMedium := $src}} + {{ $darkLarge := $src}} +{{ end }} + +{{ if lt $src.Width "1500" }} + {{ $darkLarge := $src}} +{{ end }} + +
+ + +
+
+

{{ $author.greeting }} {{ $name }}

+ {{ if $author.subtitle }} +

{{ $author.subtitle }}

+ {{ end }} + + + {{ if $sections }} + {{ range first 1 (where (sort $sections "section.weight") ".section.enable" true) }} + {{ $sectionID := replace (lower .section.name) " " "-" }} + {{ if .section.id }} + {{ $sectionID = .section.id }} + {{ end }} + + {{ end }} + {{ end }} +
+