Skip to content

Commit

Permalink
Update photoswipe lightbox to use esm version of code.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenchio committed Dec 19, 2024
1 parent 399310c commit 69b3e98
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
5 changes: 1 addition & 4 deletions layouts/blog/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
{{- define "main" }}
<script type="module">
import '/js/prettify.js';
import '/js/lightbox.js';
</script>
<script src="/vendor/photoswipe-lightbox.umd.min.js"></script>
<script src="/vendor/photoswipe.umd.min.js"></script>
<link rel="stylesheet" href="/vendor/photoswipe.css">
<script src="/js/lightbox.js"></script>
<div class="page article">
<div class="article--back">
<a class="article--back-link" href="/blog/">
Expand Down
9 changes: 9 additions & 0 deletions static/js/lightbox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import PhotoSwipeLightbox from '/vendor/photoswipe-lightbox.esm.min.js';
import PhotoSwipe from '/vendor/photoswipe.esm.min.js';

window.addEventListener("load", function () {
const link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
document.head.appendChild(link);

link.href = '/vendor/photoswipe.css';
document.querySelectorAll('img').forEach(function (img) {
if (img.parentNode.tagName === "A") {
img.parentNode.setAttribute("data-pswp-width", img.naturalWidth);
Expand Down
5 changes: 5 additions & 0 deletions static/vendor/photoswipe-lightbox.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 69b3e98

Please sign in to comment.