function initParallax() { jarallax(document.querySelectorAll('.has-parallax-feed .gh-card'), { speed: 0.8, }); } (function () { if (!document.body.classList.contains('has-background-about')) return; const about = document.querySelector('.gh-about'); if (!about) return; const image = about.querySelector('.gh-about-image'); if (!image.naturalWidth) { imagesLoaded(image, function () { about.style.setProperty('--about-height', image.clientWidth * image.naturalHeight / image.naturalWidth + 'px'); }); } })(); (function () { initParallax(); })(); (function () { const toggle = document.querySelector('[data-toggle-comments]'); if (!toggle) return; toggle.addEventListener('click', function () { document.body.classList.toggle('comments-opened'); }); })(); (function () { const element = document.querySelector('.gh-article-excerpt'); if (!element) return; let text = element.textContent; const emojiRE = /\p{EPres}|\p{ExtPict}/gu; const emojis = text.match(emojiRE); if (!emojis) return; emojis.forEach(function (emoji) { text = text.replace(emoji, `${emoji}`); }); element.innerHTML = text; })(); (function () { pagination(true, initParallax); })(); (function (window, document) { var addAnchors = () => { var headings = document.querySelectorAll('.gh-content h1, .gh-content h2, .gh-content h3, .gh-content h4, .gh-content h5, .gh-content h6') headings.forEach((heading) => { heading.insertAdjacentHTML('beforeend', ` `) const anchor = heading.querySelector('.anchor-link'); anchor.addEventListener('click', async (e) => { e.preventDefault(); const url = new URL(window.location.href); url.hash = heading.id; try { await navigator.clipboard.writeText(url.toString()); showCopiedFeedback(anchor); } catch (err) { console.error('Failed to copy:', err); anchor.setAttribute('aria-label', 'Failed to copy link'); } }); }); } function showCopiedFeedback(element) { element.classList.add('copied'); element.setAttribute('aria-label', 'Link copied to clipboard'); setTimeout(() => { element.classList.remove('copied'); element.setAttribute('aria-label', 'Copy link to this section'); }, 2000); } document.addEventListener('DOMContentLoaded', addAnchors) })(window, document);