mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 18:15:31 +00:00
fix: gallery lightbox doesn't always load
Lightbox may not load in case of gallery shortcode contained within `text` field of a landing page block (v2 blocks). Fix #2972
This commit is contained in:
1 parent
f2a7bd1229
commit
f38f65d011
3 files changed
+9
-3
No files matched your search
@@ -11,11 +11,18 @@
|
||||
{{ errorf "%s uses a `%s` block but the `%s` block was not found at `layouts/partials/%s`" $block.File.Path $block_type $block_type $block_path }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Workaround to make Hugo's .Page.Store.Set cascade up to the parent of headless pages */}}
|
||||
{{/* Mermaid block: Workaround to make Hugo's .Page.Store.Set cascade up to the parent of headless pages */}}
|
||||
{{ if $block.Page.Store.Get "has_mermaid" }}
|
||||
{{ $page.Page.Store.Set "has_mermaid" true }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Gallery block: Workaround to make Hugo's .Page.Store.Set cascade up from page blocks to the page context */}}
|
||||
{{/* Unfortunately, `.HasShortcode "gallery"` won't accept string input, only page context - so irrelevant here */}}
|
||||
{{/* Therefore, must do our own search for shortcodes within the `text` string */}}
|
||||
{{ if (gt (len (findRE `\{\{< gallery` $block.content.text 1)) 0) }}
|
||||
{{ $page.Page.Store.Set "has_gallery" true }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Begin widget styling */}}
|
||||
{{ $bg := $block.design.background }}
|
||||
{{ $style := "" }}
|
||||
|
||||
@@ -95,7 +95,6 @@
|
||||
{{ $has_gallery = true }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $scr.Set "HasNestedGalleryShortcode" $has_gallery }}
|
||||
{{ if $has_gallery | or site.Params.require_fancybox }}
|
||||
{{ printf "<link rel=\"stylesheet\" href=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" media=\"print\" onload=\"this.media='all'\">" (printf $css.fancybox.url $css.fancybox.version) $css.fancybox.sri | safeHTML }}
|
||||
{{ end }}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
{{ end }}
|
||||
|
||||
{{/* Workaround `.HasShortcode "gallery"` detection issue on `home/` WidgetPage v1 */}}
|
||||
{{ if ($scr.Get "HasNestedGalleryShortcode") | or site.Params.require_fancybox }}
|
||||
{{ if (.Page.Store.Get "has_gallery") | or site.Params.require_fancybox }}
|
||||
{{ printf "<script src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\"></script>" (printf $js.fancybox.url $js.fancybox.version) $js.fancybox.sri | safeHTML }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
Reference in new issue
Block a user