Compare commits

...

14 Commits

Author SHA1 Message Date
Mark Dumay
8d9f12d676 Merge pull request #960 from gethinode/develop
Use latest resource handling
2024-05-28 12:42:32 +02:00
Mark Dumay
1a89aa39c2 Merge branch 'main' into develop 2024-05-28 11:59:14 +02:00
Mark Dumay
6b60188702 Use latest resource handling 2024-05-28 11:58:42 +02:00
Mark Dumay
5e410040cc Merge pull request #959 from gethinode/develop
Support plain images
2024-05-28 11:50:07 +02:00
Mark Dumay
b00f39f850 Merge branch 'main' into develop 2024-05-28 11:41:16 +02:00
Mark Dumay
7e396c5a4d Support plain images 2024-05-28 11:40:38 +02:00
github-actions[bot]
4d43f0bb9b Merge pull request #958 from gethinode/dependabot/npm_and_yarn/eslint-plugin-promise-6.2.0
Bump eslint-plugin-promise from 6.1.1 to 6.2.0
2024-05-27 13:20:07 +00:00
dependabot[bot]
3512bb9dfe Bump eslint-plugin-promise from 6.1.1 to 6.2.0
Bumps [eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise) from 6.1.1 to 6.2.0.
- [Release notes](https://github.com/eslint-community/eslint-plugin-promise/releases)
- [Changelog](https://github.com/eslint-community/eslint-plugin-promise/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint-community/eslint-plugin-promise/compare/v6.1.1...v6.2.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-promise
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-27 13:15:06 +00:00
Mark Dumay
7dde897e41 Merge pull request #957 from gethinode/develop
Improve image handling
2024-05-27 11:01:32 +02:00
Mark Dumay
f2cad0fe88 Merge branch 'main' into develop 2024-05-27 10:55:17 +02:00
Mark Dumay
eed2d8f68d Merge pull request #956 from gethinode/hugo-mod-dependencies
Update Hugo module dependencies
2024-05-27 10:54:48 +02:00
Mark Dumay
d1aebe2fbe Bump package release 2024-05-27 10:48:23 +02:00
markdumay
013614b149 fix: update Hugo module dependencies 2024-05-27 08:48:19 +00:00
Mark Dumay
d55446d5cc Improve image handling 2024-05-27 10:35:06 +02:00
9 changed files with 48 additions and 24 deletions

View File

@@ -19,7 +19,9 @@ comment: >-
reference. reference.
arguments: arguments:
url: url:
type: string type:
- string
- template.URL
optional: true optional: true
comment: >- comment: >-
Path or url of the image, e.g. `img/example.jpg`. Images with multiple Path or url of the image, e.g. `img/example.jpg`. Images with multiple
@@ -128,3 +130,11 @@ arguments:
optional: true optional: true
comment: Class attribute of the figure caption, e.g. `px-4`. comment: Class attribute of the figure caption, e.g. `px-4`.
release: v0.23.0 release: v0.23.0
plain:
type: bool
default: false
optional: true
comment:
Flag to indicate if the image should render a plain image instead of an
image set. When set, no transformations are applied to the image.
release: v0.24.0-beta5

View File

@@ -15,7 +15,7 @@ As an example, the following shortcode displays an image with rounded corners an
<!-- markdownlint-disable MD037 --> <!-- markdownlint-disable MD037 -->
{{< example lang="hugo" >}} {{< example lang="hugo" >}}
{{</* image src="https://res.cloudinary.com/demo/image/upload/dog.webp" {{</* image src="https://res.cloudinary.com/demo/image/upload/dog.webp"
ratio="21x9" caption="Cloudinary image" class="rounded" */>}} ratio="21x9" caption="Cloudinary image" class="rounded" plain=true */>}}
{{< /example >}} {{< /example >}}
<!-- markdownlint-enable MD037 --> <!-- markdownlint-enable MD037 -->

2
go.mod
View File

@@ -10,7 +10,7 @@ require (
github.com/gethinode/mod-katex v1.1.0 // indirect github.com/gethinode/mod-katex v1.1.0 // indirect
github.com/gethinode/mod-leaflet v1.1.0 // indirect github.com/gethinode/mod-leaflet v1.1.0 // indirect
github.com/gethinode/mod-lottie v1.5.0 // indirect github.com/gethinode/mod-lottie v1.5.0 // indirect
github.com/gethinode/mod-utils/v2 v2.3.1 // indirect github.com/gethinode/mod-utils/v2 v2.3.3 // indirect
github.com/nextapps-de/flexsearch v0.0.0-20240110101704-4c3966709f85 // indirect github.com/nextapps-de/flexsearch v0.0.0-20240110101704-4c3966709f85 // indirect
github.com/twbs/bootstrap v5.3.3+incompatible // indirect github.com/twbs/bootstrap v5.3.3+incompatible // indirect
) )

4
go.sum
View File

@@ -202,6 +202,10 @@ github.com/gethinode/mod-utils/v2 v2.3.0 h1:e3uhlAGasvXe+cgvcmzRe05Zo4UEx86uk0Tb
github.com/gethinode/mod-utils/v2 v2.3.0/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY= github.com/gethinode/mod-utils/v2 v2.3.0/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.3.1 h1:blqynoRJ+H2SPfSU28iYheYWPH39MKNtK5HKJPghL3M= github.com/gethinode/mod-utils/v2 v2.3.1 h1:blqynoRJ+H2SPfSU28iYheYWPH39MKNtK5HKJPghL3M=
github.com/gethinode/mod-utils/v2 v2.3.1/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY= github.com/gethinode/mod-utils/v2 v2.3.1/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.3.2 h1:QxYtHqeiLfAg+38ULFr3qYwNuypcnV1KzsmmNUjbX+U=
github.com/gethinode/mod-utils/v2 v2.3.2/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.3.3 h1:dewgQgAyPJJ1lA2WhowHaFqVaeLjUNYgxDO4mE3v0F0=
github.com/gethinode/mod-utils/v2 v2.3.3/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3 h1:H/qVR5O4BXjRjD+5PZB+r4ug2BSJ2Of4RtwOntd+OKo= github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3 h1:H/qVR5O4BXjRjD+5PZB+r4ug2BSJ2Of4RtwOntd+OKo=
github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3/go.mod h1:5GdMfPAXzbA2gXBqTjC6l27kioSYzHlqDMh0+wyx7sU= github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3/go.mod h1:5GdMfPAXzbA2gXBqTjC6l27kioSYzHlqDMh0+wyx7sU=
github.com/nextapps-de/flexsearch v0.0.0-20240108021025-afd75f742f22 h1:re7L8FxbXQpnX8BgzkdUnDpsUmloGNyLmiy2ZCln8pg= github.com/nextapps-de/flexsearch v0.0.0-20240108021025-afd75f742f22 h1:re7L8FxbXQpnX8BgzkdUnDpsUmloGNyLmiy2ZCln8pg=

View File

@@ -14,13 +14,13 @@
{{- $url := .url -}} {{- $url := .url -}}
{{- $mode := .mode -}} {{- $mode := .mode -}}
{{- $modes := .modes -}} {{- $modes := .modes -}}
{{- $plain := .plain | default false }}
{{- $fallbackURL := "" -}} {{- $fallbackURL := "" -}}
{{- $anchor := "" -}} {{- $anchor := "" -}}
{{- $imgset := "" -}} {{- $imgset := "" -}}
{{- $isVector := false -}} {{- $isVector := false -}}
<!-- Split url into base and anchor when applicable (only relevant for vector images) --> <!-- Split url into base and anchor when applicable (only relevant for vector images) -->
{{- $segments := split $url "#" -}} {{- $segments := split $url "#" -}}
{{- if gt (len $segments) 2 -}} {{- if gt (len $segments) 2 -}}
@@ -65,29 +65,31 @@
{{ else }} {{ else }}
{{ $transform = "fit" }} {{ $transform = "fit" }}
{{- $res := partial "utilities/GetImage.html" (dict "url" $url "page" $page) -}} {{- $res := partial "utilities/GetImage.html" (dict "url" $url "page" $page) -}}
{{ with $res }} {{ if and $res $res.resource }}
{{ $img = $res.resource }} {{ $img = $res.resource }}
{{ if $res.mirror }}{{ $class = printf "%s mirrorred" $class }}{{ end }} {{ if $res.mirror }}{{ $class = printf "%s mirrorred" $class }}{{ end }}
{{ end }}
{{ $widths := partial "assets/helpers/GetDimension.html" (dict "ratio" "auto") }} {{ $widths := partial "assets/helpers/GetDimension.html" (dict "ratio" "auto") }}
{{ range $width := $widths -}} {{ range $width := $widths -}}
{{- $dims = $dims | append (printf "%dx%d" (int $width) (int (math.Round (mul (div (float $width) $img.Width) $img.Height)))) -}} {{- $dims = $dims | append (printf "%dx%d" (int $width) (int (math.Round (mul (div (float $width) $img.Width) $img.Height)))) -}}
{{- end -}} {{- end -}}
{{ end }}
{{ end }} {{ end }}
<!-- Derive image width and height --> <!-- Derive image width and height -->
{{ $width := "" }} {{ $width := "" }}
{{ $height := "" }} {{ $height := "" }}
{{ with $dims }} {{ if not $plain }}
{{ range $dim := (. | last 1) }} {{ with $dims }}
{{ $width = (int (index (split $dim "x") 0)) }} {{ range $dim := (. | last 1) }}
{{ $height = (int (index (split $dim "x") 1)) }} {{ $width = (int (index (split $dim "x") 0)) }}
{{ $height = (int (index (split $dim "x") 1)) }}
{{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
<!-- Generate image urls --> <!-- Generate image urls -->
{{ if hasSuffix $url "svg" }} {{ if or (hasSuffix $url "svg") $plain }}
{{- $fallbackURL = $url -}} {{- $fallbackURL = $url -}}
{{ else }} {{ else }}
{{- $fallbackURL = partial "assets/helpers/image-set.html" (dict "url" $url "img" $img "dims" ($dims | last 1) "transform" $transform "hook" $hook "format" "jpg" "includeWidth" false) -}} {{- $fallbackURL = partial "assets/helpers/image-set.html" (dict "url" $url "img" $img "dims" ($dims | last 1) "transform" $transform "hook" $hook "format" "jpg" "includeWidth" false) -}}

View File

@@ -26,6 +26,7 @@
{{- $priority := .priority -}} {{- $priority := .priority -}}
{{- if eq $priority "auto" }}{{ $priority = "" }}{{ end -}} {{- if eq $priority "auto" }}{{ $priority = "" }}{{ end -}}
{{- $sizes := .sizes | default "100vw" -}} {{- $sizes := .sizes | default "100vw" -}}
{{- $plain := .plain | default false -}}
{{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}}
{{- $url := .url -}} {{- $url := .url -}}
@@ -47,6 +48,7 @@
"priority" $priority "priority" $priority
"sizes" $sizes "sizes" $sizes
"absoluteURL" $absoluteURL "absoluteURL" $absoluteURL
"plain" $plain
) )
-}} -}}

View File

@@ -24,6 +24,7 @@
{{- $portrait := false -}} {{- $portrait := false -}}
{{- $loading := "" -}} {{- $loading := "" -}}
{{- $error := false -}} {{- $error := false -}}
{{- $plain := false -}}
{{- if .IsNamedParams -}} {{- if .IsNamedParams -}}
{{ $url = .Get "src" | default "" -}} {{ $url = .Get "src" | default "" -}}
@@ -37,6 +38,7 @@
{{ $figclass = .Get "figclass" | default "" -}} {{ $figclass = .Get "figclass" | default "" -}}
{{ with .Get "mode" }}{{ $mode = partial "utilities/CastBool.html" . }}{{ end -}} {{ with .Get "mode" }}{{ $mode = partial "utilities/CastBool.html" . }}{{ end -}}
{{ with .Get "portrait" }}{{ $portrait = partial "utilities/CastBool.html" . }}{{ end -}} {{ with .Get "portrait" }}{{ $portrait = partial "utilities/CastBool.html" . }}{{ end -}}
{{ with .Get "plain" }}{{ $plain = partial "utilities/CastBool.html" . }}{{ end -}}
{{ else -}} {{ else -}}
{{ $url = .Get 0 }} {{ $url = .Get 0 }}
{{ end -}} {{ end -}}
@@ -58,6 +60,7 @@
"figclass" $figclass "figclass" $figclass
"mode" $mode "mode" $mode
"portrait" $portrait "portrait" $portrait
"plain" $plain
"loading" $loading "loading" $loading
"page" .Page) "page" .Page)
-}} -}}

17
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.24.0-beta3", "version": "0.24.0-beta5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.24.0-beta3", "version": "0.24.0-beta5",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@fullhuman/postcss-purgecss": "^6.0.0", "@fullhuman/postcss-purgecss": "^6.0.0",
@@ -19,7 +19,7 @@
"eslint-config-standard": "^17.1.0", "eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2", "eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1", "eslint-plugin-promise": "^6.2.0",
"hugo-bin": "0.123.1", "hugo-bin": "0.123.1",
"markdownlint-cli2": "^0.13.0", "markdownlint-cli2": "^0.13.0",
"netlify-plugin-hugo-cache-resources": "^0.2.1", "netlify-plugin-hugo-cache-resources": "^0.2.1",
@@ -3067,15 +3067,18 @@
} }
}, },
"node_modules/eslint-plugin-promise": { "node_modules/eslint-plugin-promise": {
"version": "6.1.1", "version": "6.2.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.2.0.tgz",
"integrity": "sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==", "integrity": "sha512-QmAqwizauvnKOlifxyDj2ObfULpHQawlg/zQdgEixur9vl0CvZGv/LCJV2rtj3210QCoeGBzVMfMXqGAOr/4fA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0" "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}, },
"funding": {
"url": "https://opencollective.com/eslint"
},
"peerDependencies": { "peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0" "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0"
} }
}, },
"node_modules/eslint-scope": { "node_modules/eslint-scope": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.24.0-beta3", "version": "0.24.0-beta5",
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator", "description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [ "keywords": [
"hugo", "hugo",
@@ -77,7 +77,7 @@
"eslint-config-standard": "^17.1.0", "eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2", "eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1", "eslint-plugin-promise": "^6.2.0",
"hugo-bin": "0.123.1", "hugo-bin": "0.123.1",
"markdownlint-cli2": "^0.13.0", "markdownlint-cli2": "^0.13.0",
"netlify-plugin-hugo-cache-resources": "^0.2.1", "netlify-plugin-hugo-cache-resources": "^0.2.1",