diff options
| author | Eltrac <hi@guhub.cn> | 2024-12-19 15:20:55 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2024-12-19 15:20:55 +0800 |
| commit | d5e989e878e2f1a4dc9814381a589e86b38769c5 (patch) | |
| tree | cffd816e52ad5f2e7baa4c65a37a54427e5b1dc5 | |
| parent | df4366e8b041198ba922a5dad34e41672283fad9 (diff) | |
refactor: move fancybox with other libraries
| -rw-r--r-- | hugo.toml | 3 | ||||
| -rw-r--r-- | layouts/_default/single.html | 4 | ||||
| -rw-r--r-- | layouts/partials/scripts.html | 4 |
3 files changed, 6 insertions, 5 deletions
@@ -25,7 +25,8 @@ extraCSSFiles = [ ] externalJSFIles = [ 'https://unpkg.com/swup@4', - 'https://unpkg.com/vanilla-lazyload@19.1.3/dist/lazyload.min.js' + 'https://unpkg.com/vanilla-lazyload@19.1.3/dist/lazyload.min.js', + 'https://unpkg.com/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.umd.js' ] [[params.nav]] diff --git a/layouts/_default/single.html b/layouts/_default/single.html index faf70e6a..f212dd36 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -59,8 +59,4 @@ {{ end }} </article> - <!-- use fancybox --> - <!-- the reason it is replace here it that the fancybox.js is loaded after the swup.js --> - <script src="https://unpkg.com/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.umd.js"></script> - <script>Fancybox.bind("[data-fancybox]");</script> {{ partial "snippets/document-end.html" . }} diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index d8daaaa0..60ef902c 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -30,10 +30,14 @@ loadWalineComment(); var lazyLoadInstance = new LazyLoad(); lazyLoadInstance.update(); +/* === Fancybox === */ +Fancybox.bind("[data-fancybox]"); + /* === swup === */ const swup = new Swup(); swup.hooks.on('page:view', () => { loadWalineComment(); lazyLoadInstance.update(); + Fancybox.bind("[data-fancybox]"); }); </script> |
