@@ -58,32 +58,30 @@ const images = entry.data.images
5858 import { createRoot } from 'react-dom/client';
5959 import { createElement } from 'react';
6060
61- document.addEventListener('DOMContentLoaded', () => {
62- const thumbs = document.querySelectorAll('.work-image-thumb');
63-
64- thumbs.forEach((thumb) => {
65- thumb.addEventListener('click', () => {
66- const images = JSON.parse(thumb.getAttribute('data-images') || '[]');
67- const index = parseInt(thumb.getAttribute('data-index') || '0');
68-
69- const container = document.createElement('div');
70- document.body.appendChild(container);
71- const root = createRoot(container);
72-
73- const closeHandler = () => {
74- root.unmount();
75- document.body.removeChild(container);
76- };
77-
78- root.render(
79- createElement(ImageLightbox, {
80- images,
81- isOpen: true,
82- initialIndex: index,
83- onClose: closeHandler,
84- })
85- );
86- });
61+ const thumbs = document.querySelectorAll('.work-image-thumb');
62+
63+ thumbs.forEach((thumb) => {
64+ thumb.addEventListener('click', () => {
65+ const images = JSON.parse(thumb.getAttribute('data-images') || '[]');
66+ const index = parseInt(thumb.getAttribute('data-index') || '0');
67+
68+ const container = document.createElement('div');
69+ document.body.appendChild(container);
70+ const root = createRoot(container);
71+
72+ const closeHandler = () => {
73+ root.unmount();
74+ document.body.removeChild(container);
75+ };
76+
77+ root.render(
78+ createElement(ImageLightbox, {
79+ images,
80+ isOpen: true,
81+ initialIndex: index,
82+ onClose: closeHandler,
83+ })
84+ );
8785 });
8886 });
8987</script >
0 commit comments