export default function singleRevue() { const isSingleRevue = document.querySelector( '.page--single-revue' ); if (!isSingleRevue) return; handleButtons(); getRevueAuthors(); } function getRevueID() { const revueID = document .querySelector('.page--single-revue') .getAttribute('data-revue-id'); return revueID ?? null; } function handleButtons() { const socialsButtons = document.querySelectorAll( '.socials-buttons__button' ); const shareButton = document.querySelector( '.socials-buttons__button--share' ); shareButton.addEventListener('click', () => { const url = window.location.href; const title = document.title; const text = 'Check out this article: ' + url; const shareUrl = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(url); // window.open(shareUrl, '_blank'); console.log(url, title, text, shareUrl); }); } async function getRevueAuthors() { const revueID = getRevueID(); if (!revueID) return; console.log(revueID); const response = await fetch( `/wp-json/dynamiques-datas/v1/build/revue/authors?revue-id=${revueID}` ); const revueAuthors = await response.json(); }