<script>
const scripts = [
'https://cdn.jsdelivr.net/gh/willmyerscode/[email protected]/index.min.js',
'https://cdn.jsdelivr.net/gh/willmyerscode/[email protected]/section-loader.min.js'
];
const stylesheet = 'https://cdn.jsdelivr.net/gh/willmyerscode/[email protected]/section-loader.min.css';
function loadStylesheet(href) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = href;
document.head.appendChild(link);
}
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = src;
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);
});
}
function syncPaginationWithImages() {
const paginationSection = document.querySelector('section#itemPagination');
const arrowsSection = document.querySelector('[data-source="/arrows"]');
if (!paginationSection || !arrowsSection) return;
const prevLink = paginationSection.querySelector('.item-pagination-link--prev:not(.portfolio-backto)');
const nextLink = paginationSection.querySelector('.item-pagination-link--next');
const imageBlocks = arrowsSection.querySelectorAll('.sqs-block-image');
if (prevLink && imageBlocks[0]) {
const prevImage = imageBlocks[0].querySelector('a');
if (prevImage) {
prevImage.href = prevLink.href;
}
}
if (nextLink && imageBlocks[1]) {
const nextImage = imageBlocks[1].querySelector('a');
if (nextImage) {
nextImage.href = nextLink.href;
}
}
}
async function init() {
loadStylesheet(stylesheet);
for (const src of scripts) {
await loadScript(src);
}
const paginationSection = document.querySelector('.collection-663a9b99acd1b13a747c7b7c.view-item section#itemPagination');
if (paginationSection) {
const loaderDiv = document.createElement('div');
loaderDiv.setAttribute('data-wm-plugin', 'load');
loaderDiv.setAttribute('data-source', '/arrows');
paginationSection.parentNode.insertBefore(loaderDiv, paginationSection);
if (window.wmSectionLoader && typeof window.wmSectionLoader.init === 'function') {
window.wmSectionLoader.init(() => {
syncPaginationWithImages();
});
}
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
</script>