I want to load lightgallery javascript file if page contains image resource.
I can Use the .Store variable to set a flag to decide whether to load js resources.
themes\DoIt\layouts_default_markup\render-image.html
{{- if (.Store.Get "this").lightgallery - }}
<script src= "lib/lightgallery/lightgallery.min.css">
But How to load js file on demand on the home page? Because a scratch pad is attached to a Page object.
I considered checking whether there is an image in .Summary to decide whether to load the js file.
How to detect whether summary contains an image?
{{- printf "assets this is %v on %v" (.Scratch.Get "this") .Page.RelPermalink -}}
{{- if $params.lightgallery | and (.Scratch.Get "this").lightgallery -}}
output on the homepage
this is map[lightgallery:true] on /post/videos-index-problem/
assets this is map[config:map[data:map[id-1:不要忘了,为何出发]] count:2 typeitMap:map[id-1:[id-1]]] on /