From 2ce7b8633789263367bd989f899673d79726b94e Mon Sep 17 00:00:00 2001 From: Matthew Sanabria <24284972+sudomateo@users.noreply.github.com> Date: Sat, 24 Feb 2024 21:36:51 -0500 Subject: [PATCH] hugo: update hugo and go, work around theme issue There's an issue with the upstream theme on Hugo v0.123 that prevents the site from building. - https://github.com/lukeorth/poison/issues/169 --- Dockerfile | 4 +- hugo.toml | 12 ++-- layouts/partials/head/meta.html | 115 ++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 layouts/partials/head/meta.html diff --git a/Dockerfile b/Dockerfile index 77992bb..8bc81a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21.6 +FROM golang:1.22.0 # Install curl. RUN apt-get update && \ @@ -7,7 +7,7 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # Install Hugo. -ENV HUGO_VERSION=0.121.2 +ENV HUGO_VERSION=0.123.3 RUN curl -L -o /tmp/hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz && \ tar -xvf /tmp/hugo.tar.gz -C /usr/local/bin hugo && \ rm -rf /tmp/hugo.tar.gz diff --git a/hugo.toml b/hugo.toml index 8884784..e3918ee 100644 --- a/hugo.toml +++ b/hugo.toml @@ -8,12 +8,12 @@ title = "Matthew Sanabria" path = "github.com/lukeorth/poison" [params] - brand = "Matthew Sanabria" - brand_image = "https://sudomateo.nyc3.digitaloceanspaces.com/images/Matthew-Sanabria-Profile.jpeg" - dark_mode = true - description = "Helping great people become great engineers!" - rss_icon = true - rss_section = "" + brand = "Matthew Sanabria" + dark_mode = true + description = "Helping great people become great engineers!" + remote_brand_image = "https://github.com/sudomateo.png" + rss_icon = true + rss_section = "" # favicon = "" # og_image = "" diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html new file mode 100644 index 0000000..cb9c888 --- /dev/null +++ b/layouts/partials/head/meta.html @@ -0,0 +1,115 @@ +{{ .Scratch.Set "title" .Site.Title }} + +{{ .Scratch.Set "publisherIcon" .Site.Params.favicon }} +{{ if .Site.Params.publisherIcon }} + {{ .Scratch.Set "publisherIcon" .Site.Params.publisher_icon }} +{{ end }} + +{{ if eq .Kind "home" }} + {{ .Scratch.Set "title" $.Site.Params.brand }} + {{ .Scratch.Set "description" .Site.Params.Description }} +{{ else }} + {{ .Scratch.Set "description" .Description }} +{{ end }} + +{{ if .IsSection }} + {{ .Scratch.Set "title" ($.Site.Params.brand) }} + {{ .Scratch.Add "title" " - " }} + {{ .Scratch.Add "title" .LinkTitle }} +{{ end }} + +{{ if .IsPage }} + {{ .Scratch.Set "title" ($.Site.Params.brand) }} + {{ .Scratch.Add "title" " - " }} + {{ .Scratch.Add "title" .LinkTitle }} +{{ end }} + +{{ "" | safeHTML }} +{{ $image_path := .Params.image | default .Site.Params.og_image -}} +{{ $image_path_local := printf "assets/%s" $image_path -}} +{{ $image_ext := trim (path.Ext $image_path | lower) "." -}} +{{ if fileExists $image_path_local -}} +{{ $image_path:= resources.Get $image_path}} + + {{/* If not SVG, read image aspect ratio and define Twitter Card and Open Graph width and height */ -}} + {{ if ne $image_ext "svg" -}} + {{ with (imageConfig $image_path_local) -}} + {{ if (and (gt .Width 144) (gt .Height 144)) -}} + + + {{ end -}} + + + {{ end -}} + {{ end -}} + +{{ end -}} + + +