Skip to content

Commit

Permalink
config: align setup params with Hyas way
Browse files Browse the repository at this point in the history
  • Loading branch information
h-enk committed Oct 12, 2023
1 parent 7bfaf81 commit b12d9cd
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ Add mounts to `./config/_default/module.toml`:
Set parameters in `./config/_default/params.toml`:

```bash
## Hyas images
[hyas.images]
[hyas.images.landscape]
# Images (@hyas/images)
[images]
[images.landscape]
normalize = "1360x765" # "1600x900" (default)
lqip = "16x9" # "16x9" (default)
widths = [480, 640, 800, 1024]
[hyas.images.portrait]
[images.portrait]
normalize = "765x1360" # "900x1600" (default)
lqip = "9x16" # "9x16" (default)
widths = [480, 640, 800, 1024]
Expand Down
6 changes: 3 additions & 3 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ errorLevel = 'ignore' # ignore (default), warning, or error (fails the build)
highlightBroken = false # true or false (default)

## Hyas images
[hyas.images]
[hyas.images.landscape]
[images]
[images.landscape]
normalize = "1360x765" # "1600x900" (default)
lqip = "16x9" # "16x9" (default)
widths = [480, 640, 800, 1024]
[hyas.images.portrait]
[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.hyas.images.landscape.normalize | default "1600x900" }}
{{- $n := site.Params.images.landscape.normalize | default "1600x900" }}
{{- if gt $r.Height $r.Width }}
{{- $n = site.Params.hyas.images.portrait.normalize | default "900x1600" }}
{{- $n = site.Params.images.portrait.normalize | default "900x1600" }}
{{- end }}
{{- $r = $r.Fill (print $n " webp") }}

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

{{/* Get widths. */}}
{{- $w := site.Params.hyas.images.landscape.widths | default "[480 640 800 1024]" }}
{{- $w := site.Params.images.landscape.widths | default "[480 640 800 1024]" }}
{{- if gt $r.Height $r.Width }}
{{ $w = site.Params.hyas.images.portrait.widths | default "[480 640 800 1024]" }}
{{ $w = site.Params.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.hyas.images.landscape.normalize | default "1600x900" }}
{{- $n := site.Params.images.landscape.normalize | default "1600x900" }}
{{- if gt $bi.Height $bi.Width }}
{{- $n = site.Params.hyas.images.portrait.normalize | default "900x1600" }}
{{- $n = site.Params.images.portrait.normalize | default "900x1600" }}
{{- end }}
{{- $bi = $bi.Fill (print $n ) }}

{{/* Generate LQIP. */}}
{{- $l := site.Params.hyas.images.landscape.lqip | default "16x9" }}
{{- $l := site.Params.images.landscape.lqip | default "16x9" }}
{{- if gt $bi.Height $bi.Width }}
{{- $l = site.Params.hyas.images.portrait.lqip | default "9x16" }}
{{- $l = site.Params.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.hyas.images.landscape.widths | default "[480 640 800 1024]" }}
{{- $stdWidths := site.Params.images.landscape.widths | default "[480 640 800 1024]" }}
{{- if gt $bi.Height $bi.Width }}
{{ $stdWidths = site.Params.hyas.images.portrait.widths | default "[480 640 800 1024]" }}
{{ $stdWidths = site.Params.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.hyas.images.landscape.normalize | default "1600x900" }}
{{- $n := site.Params.images.landscape.normalize | default "1600x900" }}
{{- if gt $bi.Height $bi.Width }}
{{- $n = site.Params.hyas.images.portrait.normalize | default "900x1600" }}
{{- $n = site.Params.images.portrait.normalize | default "900x1600" }}
{{- end }}
{{- $bi = $bi.Fill (print $n ) }}

{{/* Generate LQIP. */}}
{{- $l := site.Params.hyas.images.landscape.lqip | default "16x9" }}
{{- $l := site.Params.images.landscape.lqip | default "16x9" }}
{{- if gt $bi.Height $bi.Width }}
{{- $l = site.Params.hyas.images.portrait.lqip | default "9x16" }}
{{- $l = site.Params.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.hyas.images.landscape.widths | default "[480 640 800 1024]" }}
{{- $stdWidths := site.Params.images.landscape.widths | default "[480 640 800 1024]" }}
{{- if gt $bi.Height $bi.Width }}
{{ $stdWidths = site.Params.hyas.images.portrait.widths | default "[480 640 800 1024]" }}
{{ $stdWidths = site.Params.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.hyas.images.landscape.normalize | default "1600x900" }}
{{- $n := site.Params.images.landscape.normalize | default "1600x900" }}
{{- if gt $bi.Height $bi.Width }}
{{- $n = site.Params.hyas.images.portrait.normalize | default "900x1600" }}
{{- $n = site.Params.images.portrait.normalize | default "900x1600" }}
{{- end }}
{{- $bi = $bi.Fill (print $n ) }}

{{/* Generate LQIP. */}}
{{- $l := site.Params.hyas.images.landscape.lqip | default "16x9" }}
{{- $l := site.Params.images.landscape.lqip | default "16x9" }}
{{- if gt $bi.Height $bi.Width }}
{{- $l = site.Params.hyas.images.portrait.lqip | default "9x16" }}
{{- $l = site.Params.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.hyas.images.landscape.widths | default "[480 640 800 1024]" }}
{{- $stdWidths := site.Params.images.landscape.widths | default "[480 640 800 1024]" }}
{{- if gt $bi.Height $bi.Width }}
{{ $stdWidths = site.Params.hyas.images.portrait.widths | default "[480 640 800 1024]" }}
{{ $stdWidths = site.Params.images.portrait.widths | default "[480 640 800 1024]" }}
{{- end }}

{{- /* Determine widths for srcset generation. */}}
Expand Down
10 changes: 5 additions & 5 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.0",
"version": "2.0.1",
"description": "Hyas images",
"author": "Hyas",
"license": "MIT",
Expand Down

0 comments on commit b12d9cd

Please sign in to comment.