Files
bridget/layouts/_default/single.json
Spedon ae1a08eb82 feat: embed threshold and index val of navbar into html/inline js (#241)
* feat: refactor image retrieval logic and improve variable initialization

- Add a new file `layouts/partials/function/getImageSlice.html`
- Initialize variables `$context`, `$Path`, and `$params`
- Set `$Path` based on the result of the `partial/function/currentMenuItem.html` partial
- Retrieve the page `$gallery` based on `$Path`
- Return all resources of type `image` from `$gallery`

* refactor: adapt getImageSlice function to `single.json`

* feat: refactor navigation UI components to use static go template

* feat: update navigation functionality and threshold rendering
2024-01-20 18:03:26 +08:00

32 lines
998 B
JSON

{{- $context := . -}}
{{- $params := .Page.Params | merge .Site.Params.Page -}}
{{- with partial "function/getImageSlice.html" . -}}
{{- $index := len . -}}
{{- $context.Scratch.Add "img" slice -}}
{{- range sort . "Name" "desc" -}}
{{- $image := . -}}
{{- $index = sub $index 1 -}}
{{- $alt := .Name -}}
{{- with $params.unifiedAlt -}}
{{- $alt = . -}}
{{- end -}}
{{- $lores := .Resize (site.Params.loResOpt | default "700x webp Lanczos q60") -}}
{{- $hires := .Resize (site.Params.hiResOpt | default "2000x webp Lanczos q75") -}}
{{- $context.Scratch.Add "img" (dict
"index" (int $index)
"alt" (string $alt)
"loUrl" (string $lores.RelPermalink)
"loImgH" (int $lores.Height)
"loImgW" (int $lores.Width)
"hiUrl" (string $hires.RelPermalink)
"hiImgH" (int $hires.Height)
"hiImgW" (int $hires.Width)
)
-}}
{{- end -}}
{{ $context.Scratch.Get "img" | jsonify }}
{{- else -}}
[]
{{- end -}}