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