champs url dans les icones de la map et suppr du data attribute nid sur les liens

This commit is contained in:
Valentin
2024-11-13 11:42:30 +01:00
parent c82fc633aa
commit f2680fc65a
5 changed files with 33 additions and 40 deletions

View File

@@ -27,7 +27,7 @@ export const useContentStore = defineStore('content', {
this.resetStore(false);
const contentTypes = [ 'etape', 'static' ];
try {
let rawContent,
let rawContent,
contentType,
response;
@@ -58,11 +58,11 @@ export const useContentStore = defineStore('content', {
// vignette
const vignetteFetch = await this.fetchDeeperContent('field_vignette', rawContent.relationships);
if (vignetteFetch) {
this.content.vignette = {
this.content.vignette = {
url: vignetteFetch.attributes.uri.url,
alt: rawContent.relationships.field_vignette.data.meta.alt
};
}
}
if (contentType === 'etape') {
// coordinates
@@ -84,12 +84,12 @@ export const useContentStore = defineStore('content', {
// previous / next
await this.getRelatedEtape('previous', response.data.data, path);
await this.getRelatedEtape('next', response.data.data, path);
}
}
// parties
const fieldParties = contentType === 'etape' ? 'field_parties' : 'field_parties_static';
const partiesFetch = await this.fetchDeeperContent(fieldParties, rawContent.relationships);
if (partiesFetch) {
this.content.parties = [];
for (let partie of partiesFetch) {
@@ -100,7 +100,7 @@ export const useContentStore = defineStore('content', {
switch (partieType) {
case 'carte_sensible':
const carteSensibleFetch = await this.fetchDeeperContent('field_image_carte', partie.relationships);
const carteSensibleFetch = await this.fetchDeeperContent('field_image_carte', partie.relationships);
if (carteSensibleFetch) {
partieContent.carteSensible = {
url: carteSensibleFetch.attributes.uri.url,
@@ -110,7 +110,7 @@ export const useContentStore = defineStore('content', {
break;
case 'titre_texte':
partieContent.titre = partie.attributes.field_titre;
partieContent.texte = partie.attributes.field_texte.value;
partieContent.texte = partie.attributes.field_texte.value;
break;
case 'chiffres_cles':
const chiffresClesFetch = await this.fetchDeeperContent('field_chiffres_clefs', partie.relationships);
@@ -144,7 +144,7 @@ export const useContentStore = defineStore('content', {
partieContent.entretien.personnes = [];
for (let personne of personnesFetch) {
const portraitFetch = await this.fetchDeeperContent('field_portrait', personne.relationships);
if (portraitFetch) {
if (portraitFetch) {
partieContent.entretien.personnes.push({
portrait: portraitFetch.attributes.uri.url,
alt: personne.relationships.field_portrait.data.meta.alt,
@@ -158,7 +158,7 @@ export const useContentStore = defineStore('content', {
question: qr.attributes.field_question,
reponse: qr.attributes.field_reponse.value,
});
}
}
}
break;
case 'exergue':
@@ -169,7 +169,7 @@ export const useContentStore = defineStore('content', {
for (let video of partie.attributes.field_videos) {
const videoId = video.split('?v=')[1];
const videoUrl = `https://www.youtube.com/embed/${videoId}`;
partieContent.videos.push(videoUrl);
partieContent.videos.push(videoUrl);
}
break;
}
@@ -179,8 +179,8 @@ export const useContentStore = defineStore('content', {
} catch (error) {
this.error = 'Failed to fetch data';
console.error('Issue with getNodeData', error);
} finally {
this.loading = false;
} finally {
this.loading = false;
}
},
getCleanDate(date) {
@@ -195,7 +195,7 @@ export const useContentStore = defineStore('content', {
const baseUrl = window.location.protocol + "//" + window.location.host;
for (let etape of allEtapesData) {
for (let tag of etape.attributes.metatag) {
if (tag.tag === "link" && tag.attributes.href === baseUrl + relatedPath) {
if (tag.tag === "link" && tag.attributes.href === baseUrl + relatedPath) {
const vignetteFetch = await REST.get(etape.relationships.field_vignette.links.related.href);
this.content[direction] = {
url: tag.attributes.href,
@@ -223,7 +223,7 @@ export const useContentStore = defineStore('content', {
if (path.endsWith(liHref)) {
const previousEtapeItemPath = li.previousElementSibling?.querySelector('a').getAttribute('href');
const nextEtapeItemPath = li.nextElementSibling?.querySelector('a').getAttribute('href');
if (previousEtapeItemPath && direction === 'previous') {
let prevContent = await getRelatedEtapeContent(previousEtapeItemPath, allEtapesData);
return prevContent;
@@ -256,4 +256,4 @@ export const useContentStore = defineStore('content', {
this.error = null;
}
},
});
});

View File

@@ -37,26 +37,27 @@ export const useLayoutStore = defineStore('layout', {
const menuTitle = document.querySelector('#menu-title');
const menuH2 = document.querySelector('#menu > h2');
menuBurger.addEventListener('click', (e) => {
menuBurger.addEventListener('click', (e) => {
setTimeout(() => {
if (!this.isHamburgerMenuOpen) menuContainer.style.display = 'block';
menuContainer.classList.toggle('open');
menuTitle.classList.toggle('open');
menuBurger.classList.toggle('open');
menuH2.classList.toggle('open');
if (this.isHamburgerMenuOpen) {
setTimeout(() => {
menuContainer.style.display = 'none';
setTimeout(() => {
// console.log('isHamburgerMenuOpen', this.isHamburgerMenuOpen);
if (this.isHamburgerMenuOpen) {
menuContainer.style.display = 'none';
}
this.isHamburgerMenuOpen = !this.isHamburgerMenuOpen;
}, 300);
}
}, 50);
document.addEventListener('click', (e) => {
if (!menuContainer.contains(e.target) && !menuBurger.contains(e.target)) {
menuContainer.classList.remove('open');
menuTitle.classList.remove('open');
menuBurger.classList.remove('open');
menuH2.classList.remove('open');
menuH2.classList.remove('open');
setTimeout(() => {
if (this.isHamburgerMenuOpen) {
menuContainer.style.display = 'none';
@@ -68,4 +69,4 @@ export const useLayoutStore = defineStore('layout', {
});
}
},
})
})