Skip to content

Commit

Permalink
fix: rename params for Hugo reserved params
Browse files Browse the repository at this point in the history
  • Loading branch information
h-enk committed Oct 13, 2023
1 parent f8ce95a commit f92668e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ Set parameters in `./config/_default/params.toml`:

```bash
# Images (@hyas/images)
[images]
[images.landscape]
[hyas_images]
[hyas_images.landscape]
normalize = "1360x765" # "1600x900" (default)
lqip = "16x9" # "16x9" (default)
widths = [480, 640, 800, 1024]
[images.portrait]
[hyas_images.portrait]
normalize = "765x1360" # "900x1600" (default)
lqip = "9x16" # "9x16" (default)
widths = [480, 640, 800, 1024]
Expand Down
10 changes: 5 additions & 5 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
## Debug
# Debug
[render_hooks.image]
errorLevel = 'ignore' # ignore (default), warning, or error (fails the build)

[render_hooks.link]
errorLevel = 'ignore' # ignore (default), warning, or error (fails the build)
highlightBroken = false # true or false (default)

## Hyas images
[images]
[images.landscape]
# Images (@hyas/images)
[hyas_images]
[hyas_images.landscape]
normalize = "1360x765" # "1600x900" (default)
lqip = "16x9" # "16x9" (default)
widths = [480, 640, 800, 1024]
[images.portrait]
[hyas_images.portrait]
normalize = "765x1360" # "900x1600" (default)
lqip = "9x16" # "9x16" (default)
widths = [480, 640, 800, 1024]
12 changes: 6 additions & 6 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,23 @@
{{- end }}

{{/* Normalize and convert to WebP. */}}
{{- $n := site.Params.images.landscape.normalize | default "1600x900" }}
{{- $n := site.Params.hyas_images.landscape.normalize | default "1600x900" }}
{{- if gt $r.Height $r.Width }}
{{- $n = site.Params.images.portrait.normalize | default "900x1600" }}
{{- $n = site.Params.hyas_images.portrait.normalize | default "900x1600" }}
{{- end }}
{{- $r = $r.Fill (print $n " webp") }}

{{/* Generate LQIP. */}}
{{- $l := site.Params.images.landscape.lqip | default "16x9" }}
{{- $l := site.Params.hyas_images.landscape.lqip | default "16x9" }}
{{- if gt $r.Height $r.Width }}
{{- $l = site.Params.images.portrait.lqip | default "9x16" }}
{{- $l = site.Params.hyas_images.portrait.lqip | default "9x16" }}
{{- end }}
{{- $l = $r.Resize $l }}

{{/* Get widths. */}}
{{- $w := site.Params.images.landscape.widths | default "[480 640 800 1024]" }}
{{- $w := site.Params.hyas_images.landscape.widths | default "[480 640 800 1024]" }}
{{- if gt $r.Height $r.Width }}
{{ $w = site.Params.images.portrait.widths | default "[480 640 800 1024]" }}
{{ $w = site.Params.hyas_images.portrait.widths | default "[480 640 800 1024]" }}
{{- end }}

{{/* Generate srcset. */}}
Expand Down
12 changes: 6 additions & 6 deletions layouts/partials/figure.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,16 @@
{{- end }}

{{/* Normalize base image (bi). */}}
{{- $n := site.Params.images.landscape.normalize | default "1600x900" }}
{{- $n := site.Params.hyas_images.landscape.normalize | default "1600x900" }}
{{- if gt $bi.Height $bi.Width }}
{{- $n = site.Params.images.portrait.normalize | default "900x1600" }}
{{- $n = site.Params.hyas_images.portrait.normalize | default "900x1600" }}
{{- end }}
{{- $bi = $bi.Fill (print $n ) }}

{{/* Generate LQIP. */}}
{{- $l := site.Params.images.landscape.lqip | default "16x9" }}
{{- $l := site.Params.hyas_images.landscape.lqip | default "16x9" }}
{{- if gt $bi.Height $bi.Width }}
{{- $l = site.Params.images.portrait.lqip | default "9x16" }}
{{- $l = site.Params.hyas_images.portrait.lqip | default "9x16" }}
{{- end }}
{{- $l = $bi.Resize $l }}

Expand Down Expand Up @@ -286,9 +286,9 @@
{{- end }}

{{/* Get widths from config. */}}
{{- $stdWidths := site.Params.images.landscape.widths | default "[480 640 800 1024]" }}
{{- $stdWidths := site.Params.hyas_images.landscape.widths | default "[480 640 800 1024]" }}
{{- if gt $bi.Height $bi.Width }}
{{ $stdWidths = site.Params.images.portrait.widths | default "[480 640 800 1024]" }}
{{ $stdWidths = site.Params.hyas_images.portrait.widths | default "[480 640 800 1024]" }}
{{- end }}

{{- /* Determine widths for srcset generation. */}}
Expand Down
12 changes: 6 additions & 6 deletions layouts/partials/img.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@
{{- end }}

{{/* Normalize base image (bi). */}}
{{- $n := site.Params.images.landscape.normalize | default "1600x900" }}
{{- $n := site.Params.hyas_images.landscape.normalize | default "1600x900" }}
{{- if gt $bi.Height $bi.Width }}
{{- $n = site.Params.images.portrait.normalize | default "900x1600" }}
{{- $n = site.Params.hyas_images.portrait.normalize | default "900x1600" }}
{{- end }}
{{- $bi = $bi.Fill (print $n ) }}

{{/* Generate LQIP. */}}
{{- $l := site.Params.images.landscape.lqip | default "16x9" }}
{{- $l := site.Params.hyas_images.landscape.lqip | default "16x9" }}
{{- if gt $bi.Height $bi.Width }}
{{- $l = site.Params.images.portrait.lqip | default "9x16" }}
{{- $l = site.Params.hyas_images.portrait.lqip | default "9x16" }}
{{- end }}
{{- $l = $bi.Resize $l }}

Expand Down Expand Up @@ -284,9 +284,9 @@
{{- end }}

{{/* Get widths from config. */}}
{{- $stdWidths := site.Params.images.landscape.widths | default "[480 640 800 1024]" }}
{{- $stdWidths := site.Params.hyas_images.landscape.widths | default "[480 640 800 1024]" }}
{{- if gt $bi.Height $bi.Width }}
{{ $stdWidths = site.Params.images.portrait.widths | default "[480 640 800 1024]" }}
{{ $stdWidths = site.Params.hyas_images.portrait.widths | default "[480 640 800 1024]" }}
{{- end }}

{{- /* Determine widths for srcset generation. */}}
Expand Down
12 changes: 6 additions & 6 deletions layouts/partials/picture.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@
{{- end }}

{{/* Normalize base image (bi). */}}
{{- $n := site.Params.images.landscape.normalize | default "1600x900" }}
{{- $n := site.Params.hyas_images.landscape.normalize | default "1600x900" }}
{{- if gt $bi.Height $bi.Width }}
{{- $n = site.Params.images.portrait.normalize | default "900x1600" }}
{{- $n = site.Params.hyas_images.portrait.normalize | default "900x1600" }}
{{- end }}
{{- $bi = $bi.Fill (print $n ) }}

{{/* Generate LQIP. */}}
{{- $l := site.Params.images.landscape.lqip | default "16x9" }}
{{- $l := site.Params.hyas_images.landscape.lqip | default "16x9" }}
{{- if gt $bi.Height $bi.Width }}
{{- $l = site.Params.images.portrait.lqip | default "9x16" }}
{{- $l = site.Params.hyas_images.portrait.lqip | default "9x16" }}
{{- end }}
{{- $l = $bi.Resize $l }}

Expand Down Expand Up @@ -284,9 +284,9 @@
{{- end }}

{{/* Get widths from config. */}}
{{- $stdWidths := site.Params.images.landscape.widths | default "[480 640 800 1024]" }}
{{- $stdWidths := site.Params.hyas_images.landscape.widths | default "[480 640 800 1024]" }}
{{- if gt $bi.Height $bi.Width }}
{{ $stdWidths = site.Params.images.portrait.widths | default "[480 640 800 1024]" }}
{{ $stdWidths = site.Params.hyas_images.portrait.widths | default "[480 640 800 1024]" }}
{{- end }}

{{- /* Determine widths for srcset generation. */}}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyas/images",
"version": "2.0.1",
"version": "2.0.2",
"description": "Hyas images",
"author": "Hyas",
"license": "MIT",
Expand Down

0 comments on commit f92668e

Please sign in to comment.