Skip to content

Commit

Permalink
Only implement on-demand loading of lightgallery on the page.
Browse files Browse the repository at this point in the history
  • Loading branch information
wu0407 committed Nov 6, 2024
1 parent e68974c commit 8d7dc00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- $lightgallery := .Page.Params.lightgallery | default site.Params.Page.lightgallery | default false -}}
{{- .Page.Scratch.SetInMap "this" "lightgallery" $lightgallery -}}
{{- printf "this is %v on %v time %v" (.Page.Scratch.Get "this") .Page.RelPermalink time.Now -}}
{{- $optim := slice
(dict "Process" "resize 800x webp q75" "descriptor" "800w")
(dict "Process" "resize 1200x webp q75" "descriptor" "1200w")
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
{{- end -}}

{{- /* lightgallery.js */ -}}
{{- if $params.lightgallery -}}
{{- printf "assets this is %v on %v time %v" (.Scratch.Get "this") .Page.RelPermalink time.Now -}}
{{- if or .IsHome (and $params.lightgallery (.Scratch.Get "this").lightgallery) -}}
{{- $source := $cdn.lightgalleryCSS | default "lib/lightgallery/lightgallery.min.css" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}}
{{- $source := $cdn.lightgalleryJS | default "lib/lightgallery/lightgallery.min.js" -}}
Expand Down
4 changes: 3 additions & 1 deletion layouts/partials/init.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
{{- end -}}

{{- .Scratch.Set "params" $params -}}
{{- .Scratch.Set "this" dict -}}
{{- if not .IsPage -}}
{{- .Scratch.Set "this" dict -}}
{{- end -}}

{{- partial "plugin/compatibility.html" . -}}

0 comments on commit 8d7dc00

Please sign in to comment.