FEATURES Enhancing hydratation behaviour
This commit is contained in:
parent
b3a905058b
commit
5965b4356e
|
|
@ -5,7 +5,8 @@ export default function singleRevue() {
|
||||||
if (!isSingleRevue) return;
|
if (!isSingleRevue) return;
|
||||||
|
|
||||||
handleButtons();
|
handleButtons();
|
||||||
getRevueAuthors();
|
hydrateRevueAuthors();
|
||||||
|
handleAuthorsButton();
|
||||||
}
|
}
|
||||||
function getRevueID() {
|
function getRevueID() {
|
||||||
const revueID = document
|
const revueID = document
|
||||||
|
|
@ -14,6 +15,14 @@ function getRevueID() {
|
||||||
return revueID ?? null;
|
return revueID ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleAuthorsButton() {
|
||||||
|
const authorsButton = document.querySelector(
|
||||||
|
'.authors-button'
|
||||||
|
);
|
||||||
|
authorsButton.addEventListener('click', () => {
|
||||||
|
hydrateRevueAuthors();
|
||||||
|
});
|
||||||
|
}
|
||||||
function handleButtons() {
|
function handleButtons() {
|
||||||
const socialsButtons = document.querySelectorAll(
|
const socialsButtons = document.querySelectorAll(
|
||||||
'.socials-buttons__button'
|
'.socials-buttons__button'
|
||||||
|
|
@ -23,25 +32,27 @@ function handleButtons() {
|
||||||
'.socials-buttons__button--share'
|
'.socials-buttons__button--share'
|
||||||
);
|
);
|
||||||
shareButton.addEventListener('click', () => {
|
shareButton.addEventListener('click', () => {
|
||||||
const url = window.location.href;
|
// const url = window.location.href;
|
||||||
const title = document.title;
|
// const title = document.title;
|
||||||
const text = 'Check out this article: ' + url;
|
// const text = 'Check out this article: ' + url;
|
||||||
const shareUrl =
|
// const shareUrl =
|
||||||
'https://www.facebook.com/sharer/sharer.php?u=' +
|
// 'https://www.facebook.com/sharer/sharer.php?u=' +
|
||||||
encodeURIComponent(url);
|
// encodeURIComponent(url);
|
||||||
// window.open(shareUrl, '_blank');
|
// window.open(shareUrl, '_blank');
|
||||||
|
|
||||||
console.log(url, title, text, shareUrl);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRevueAuthors() {
|
async function hydrateRevueAuthors() {
|
||||||
const revueID = getRevueID();
|
const revueID = getRevueID();
|
||||||
if (!revueID) return;
|
if (!revueID) return;
|
||||||
console.log(revueID);
|
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`/wp-json/dynamiques-datas/v1/build/revue/authors?revue-id=${revueID}`
|
`/wp-json/dynamiques-datas/v1/build/revue/authors?revue-id=${revueID}`
|
||||||
);
|
);
|
||||||
const revueAuthors = await response.json();
|
const revueAuthors = await response.json();
|
||||||
|
// console.log(revueAuthors);
|
||||||
|
|
||||||
|
const authorsList =
|
||||||
|
document.querySelector('.authors-list');
|
||||||
|
authorsList.innerHTML = revueAuthors.html_template;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user