UNPKG

vuepress-plugin-lightgallery

Version:
3 lines (2 loc) 1.06 kB
import{onContentUpdated as c,defineClientConfig as u}from"vuepress/client";import f from"lightgallery/lightgallery.es5.js";import{defineComponent as p,shallowRef as d,h as y,onUnmounted as g}from"vue";import{useLightGalleryPlugins as h}from"@temp/lightgallery/plugins.js";import"lightgallery/scss/lightgallery.scss";import{u as C}from"./index-CY47DMNa.js";const v=r=>r.map(({alt:t,srcset:e,src:o})=>({src:o,srcset:e,thumb:o||e,alt:t,subHtml:t}));var E=p({name:"LightGallery",setup(){const r=C(),t=d();let e=null,o;const s=async()=>{const n=o=new Date().getTime(),i=await h();if(n===o){e?.destroy();const l=Array.from(document.querySelectorAll(__LG_SELECTOR__));e=new f(t.value,{...r,dynamic:!0,dynamicEl:v(l),licenseKey:"VSY7R-J@WED-CJY76-UMDXQ",plugins:i.map(({default:a})=>a)}),l.forEach((a,m)=>{a.addEventListener("click",()=>{e?.openGallery(m)})})}};return c(async n=>{n!=="beforeUnmount"&&await s()}),g(()=>e?.destroy()),()=>y("div",{ref:t,class:"lightgallery-vuepress"})}}),G=u({rootComponents:[E]});export{G as default}; //# sourceMappingURL=config.js.map