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

@ -59,10 +59,12 @@ export const useContentStore = defineStore('content', {
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);
if (vignetteFetch) {
this.etape.vignette = { this.etape.vignette = {
url: vignetteFetch.attributes.uri.url, url: vignetteFetch.attributes.uri.url,
alt: etape.relationships.field_vignette.data.meta.alt 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 = {
@ -217,13 +219,8 @@ export const useContentStore = defineStore('content', {
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) { for (let page of response.data.data) {
if (page.attributes.drupal_internal__nid == nid) {
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;
@ -231,10 +228,12 @@ export const useContentStore = defineStore('content', {
} }
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);
if (vignetteFetch) {
this.page.vignette = { this.page.vignette = {
url: vignetteFetch.attributes.uri.url, url: vignetteFetch.attributes.uri.url,
alt: page.relationships.field_vignette.data.meta.alt 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) {