From 54396f4dc0d79ebaf036d177460e7c0f7bbe51e7 Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Mon, 20 May 2024 13:23:26 +0200 Subject: [PATCH 1/6] Fix dimensions rounding errors --- data/dimensions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/dimensions.yml b/data/dimensions.yml index 5ccd0d7f..e7b09057 100644 --- a/data/dimensions.yml +++ b/data/dimensions.yml @@ -13,7 +13,7 @@ - 992x661 - 1200x800 - 1400x933 - - 2800x1866 + - 2800x1867 - ratio: 1x1 dimensions: - 576x576 @@ -29,7 +29,7 @@ - 992x558 - 1200x675 - 1400x788 - - 2800x1576 + - 2800x1575 - ratio: 21x9 dimensions: - 576x247 From 89b81cf1b881306eae0e24a108140c511469b267 Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Mon, 20 May 2024 14:46:06 +0200 Subject: [PATCH 2/6] Handle undefined dimensions --- layouts/partials/assets/helpers/image-definition.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/layouts/partials/assets/helpers/image-definition.html b/layouts/partials/assets/helpers/image-definition.html index 22a5892d..0352701b 100644 --- a/layouts/partials/assets/helpers/image-definition.html +++ b/layouts/partials/assets/helpers/image-definition.html @@ -72,9 +72,11 @@ {{ $width := "" }} {{ $height := "" }} -{{ range $dim := ($dims | last 1) }} - {{ $width = (int (index (split $dim "x") 0)) }} - {{ $height = (int (index (split $dim "x") 1)) }} +{{ with $dims }} + {{ range $dim := (. | last 1) }} + {{ $width = (int (index (split $dim "x") 0)) }} + {{ $height = (int (index (split $dim "x") 1)) }} + {{ end }} {{ end }} From 01b51f6ef1ca9deca5be746f76943c9415784136 Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Mon, 20 May 2024 14:46:30 +0200 Subject: [PATCH 3/6] Provide default dimensions when site data is unavailable --- .../partials/assets/helpers/GetDimension.html | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/layouts/partials/assets/helpers/GetDimension.html b/layouts/partials/assets/helpers/GetDimension.html index 0c3644b1..24529913 100644 --- a/layouts/partials/assets/helpers/GetDimension.html +++ b/layouts/partials/assets/helpers/GetDimension.html @@ -3,11 +3,23 @@ --> {{ $ratio := .ratio }} - {{ $dim := "" }} -{{ $matches := first 1 (where site.Data.dimensions "ratio" $ratio) }} -{{ if eq ($matches | len) 1 }} - {{ $dim = (index $matches 0).dimensions }} +{{ $default := dict "4x3" "1400x1050" "3x2" "1400x933" "1x1" "1400x1400" "16x9" "1400x788" "21x9" "1400x600" "auto" "1400" }} + + +{{ $config := "dimensions" }} +{{ with index site.Params "dam" }}{{ with index . "dimensions" }}{{ $config = . }}{{ end }}{{ end }} +{{ $config = path.Join (path.Dir $config) (path.BaseName $config) }} + +{{ with index site.Data $config }} + {{ $matches := first 1 (where . "ratio" $ratio) }} + {{ if eq ($matches | len) 1 }} + {{ $dim = (index $matches 0).dimensions }} + {{ end }} +{{ end }} + +{{ if not $dim }} + {{ $dim = slice (index $default $ratio) }} {{ end }} {{ return $dim }} From eb65b94ef4cbd4fb83086ab2c11a782b96c03b25 Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Mon, 20 May 2024 14:47:10 +0200 Subject: [PATCH 4/6] Fix fallback URL of Cloudinary images --- layouts/partials/assets/adapters/cloudinary.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/assets/adapters/cloudinary.html b/layouts/partials/assets/adapters/cloudinary.html index 1599e590..78624c0b 100644 --- a/layouts/partials/assets/adapters/cloudinary.html +++ b/layouts/partials/assets/adapters/cloudinary.html @@ -33,7 +33,7 @@ {{ $operation := "" }} {{ if $format }} {{ $operation = printf "%s,h_%d,w_%d" $transform $height $width }} - {{ $file = printf "%s.%s" (path.BaseName $file) $format }} + {{ $file = printf "%s.%s" (strings.TrimSuffix (path.Ext $file) $file) $format }} {{ else }} {{ $operation = printf "f_auto,%s,h_%d,w_%d" $transform $height $width }} {{ end }} From 0636708dacbbc1e56969e523e6aaad83c756bd3f Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Mon, 20 May 2024 14:48:10 +0200 Subject: [PATCH 5/6] Add DAM provider config --- exampleSite/config/_default/params.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 62611757..38790794 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -70,6 +70,14 @@ [messages] placement = "bottom-right" +[dam] + dimensions = "dimensions.yml" + +[[dam.providers]] + name = "Cloudinary" + pattern = "cloudinary" + adapter = "assets/adapters/cloudinary.html" + [sharing] enabled = true sort = "weight" From bdcdeb9b5585e9d4a6a7d96cf30edeac952a664e Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Mon, 20 May 2024 14:48:39 +0200 Subject: [PATCH 6/6] Bump package release --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 27994d84..3547a042 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gethinode/hinode", - "version": "0.24.0-alpha2", + "version": "0.24.0-alpha3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@gethinode/hinode", - "version": "0.24.0-alpha2", + "version": "0.24.0-alpha3", "license": "MIT", "devDependencies": { "@fullhuman/postcss-purgecss": "^6.0.0", diff --git a/package.json b/package.json index 1edd086e..bd7e8b5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gethinode/hinode", - "version": "0.24.0-alpha2", + "version": "0.24.0-alpha3", "description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator", "keywords": [ "hugo",