correction pb d'accès aux pages statiques 3 - fonctionne si il n'y a pas de vignette

This commit is contained in:
Valentin 2024-10-11 15:05:03 +02:00
parent 2ed8980a01
commit 5f8baebb2f
1 changed files with 17 additions and 18 deletions

View File

@ -58,11 +58,13 @@ export const useContentStore = defineStore('content', {
this.etape.title = etape.attributes.title; this.etape.title = etape.attributes.title;
this.etape.adresse = etape.attributes.field_adresse; this.etape.adresse = etape.attributes.field_adresse;
this.etape.etape_number = etape.attributes.field_arret_numero; this.etape.etape_number = etape.attributes.field_arret_numero;
const vignetteFetch = await this.fetchContent('field_vignette', etape.relationships); const vignetteFetch = await this.fetchContent('field_vignette', etape.relationships);
this.etape.vignette = { if (vignetteFetch) {
url: vignetteFetch.attributes.uri.url, this.etape.vignette = {
alt: etape.relationships.field_vignette.data.meta.alt url: vignetteFetch.attributes.uri.url,
}; alt: etape.relationships.field_vignette.data.meta.alt
};
}
this.etape.couleur = etape.attributes.field_couleur; this.etape.couleur = etape.attributes.field_couleur;
this.etape.dates = { this.etape.dates = {
@ -216,25 +218,22 @@ export const useContentStore = defineStore('content', {
this.resetStore(); this.resetStore();
this.map = map; this.map = map;
try { try {
const response = await REST.get(`/jsonapi/node/static/`); const response = await REST.get(`/jsonapi/node/static/`);
console.log("CONTENT, response : ", response); for (let page of response.data.data) {
if (page.attributes.drupal_internal__nid == nid) {
for (let page of response.data.data) {
console.log("CONTENT, page.attributes : ", page.attributes);
if (page.attributes?.drupal_internal__nid == nid) {
for (let metatag of page.attributes.metatag) { for (let metatag of page.attributes.metatag) {
if (metatag.tag === "link") { if (metatag.tag === "link") {
this.href = metatag.attributes.href; this.href = metatag.attributes.href;
} }
} }
this.page.title = page.attributes.title; this.page.title = page.attributes.title;
const vignetteFetch = await this.fetchContent('field_vignette', page.relationships); const vignetteFetch = await this.fetchContent('field_vignette', page.relationships);
this.page.vignette = { if (vignetteFetch) {
url: vignetteFetch.attributes.uri.url, this.page.vignette = {
alt: page.relationships.field_vignette.data.meta.alt url: vignetteFetch.attributes.uri.url,
}; alt: page.relationships.field_vignette.data.meta.alt
};
}
const partiesFetch = await this.fetchContent('field_parties_static', page.relationships); const partiesFetch = await this.fetchContent('field_parties_static', page.relationships);
if (partiesFetch) { if (partiesFetch) {