REFACTOR and first call to api
This commit is contained in:
parent
306e1f898e
commit
785eb5f0d2
|
|
@ -4,16 +4,22 @@ export default function singleRevue() {
|
||||||
);
|
);
|
||||||
if (!isSingleRevue) return;
|
if (!isSingleRevue) return;
|
||||||
|
|
||||||
const socialsButtons = isSingleRevue.querySelectorAll(
|
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'
|
'.socials-buttons__button'
|
||||||
);
|
);
|
||||||
// socialsButtons.forEach((button) => {
|
|
||||||
// button.addEventListener('click', () => {
|
|
||||||
// alert('clicked');
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
const shareButton = isSingleRevue.querySelector(
|
const shareButton = document.querySelector(
|
||||||
'.socials-buttons__button--share'
|
'.socials-buttons__button--share'
|
||||||
);
|
);
|
||||||
shareButton.addEventListener('click', () => {
|
shareButton.addEventListener('click', () => {
|
||||||
|
|
@ -28,3 +34,14 @@ export default function singleRevue() {
|
||||||
console.log(url, title, text, shareUrl);
|
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();
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user