diff --git a/web/themes/custom/caravane/assets/js/utils/content/multiItemPages.js b/web/themes/custom/caravane/assets/js/utils/content/multiItemPages.js index 0ab300c..2bfd28e 100644 --- a/web/themes/custom/caravane/assets/js/utils/content/multiItemPages.js +++ b/web/themes/custom/caravane/assets/js/utils/content/multiItemPages.js @@ -3,18 +3,18 @@ import { getCleanDate, getRessourceItemCard } from './contentFetchUtils'; export async function getPartenaires(rawContent) { const logoPromises = rawContent.map(item => - REST.get(item.relationships.field_logo.links.related.href) + REST.get(item.relationships.field_logo?.links.related.href) .then(logoFetch => ({ - title: item.attributes.title, - description: item.attributes.body.value, - weight: item.attributes.field_poid, - link_url: item.attributes.field_lien.uri, - logo_alt: item.relationships.field_logo.data.meta.alt, + title: item.attributes?.title, + description: item.attributes?.body?.value, + weight: item.attributes?.field_poid, + link_url: item.attributes?.field_lien?.uri, + logo_alt: item.relationships?.field_logo?.data?.meta.alt, logo_url: { - original: logoFetch.data.data.attributes.uri.url, - small: logoFetch.data.data.attributes.image_style_uri.content_small, - medium: logoFetch.data.data.attributes.image_style_uri.content_medium, - large: logoFetch.data.data.attributes.image_style_uri.content_large, + original: logoFetch.data.data?.attributes.uri.url, + small: logoFetch.data.data?.attributes.image_style_uri.content_small, + medium: logoFetch.data.data?.attributes.image_style_uri.content_medium, + large: logoFetch.data.data?.attributes.image_style_uri.content_large, } })) ); @@ -24,28 +24,28 @@ export async function getPartenaires(rawContent) { export async function getGouvernance(rawContent) { const itemPromises = rawContent.map(item => - REST.get(item.relationships.field_personne_s.links.related.href) + REST.get(item.relationships.field_personne_s?.links.related.href) .then(async personnesFetch => { const portraitPromises = personnesFetch.data.data.map(personne => - REST.get(personne.relationships.field_portrait.links.related.href) + REST.get(personne.relationships.field_portrait?.links.related.href) .then(portraitFetch => ({ nom: personne.attributes.field_nom, prenom: personne.attributes.field_prenom, description: personne.attributes.field_description, photo_meta: personne.relationships.field_portrait.data?.meta.alt, photo_url: portraitFetch.data.data ? { - original: portraitFetch.data.data.attributes.uri.url, - small: portraitFetch.data.data.attributes.image_style_uri.content_small, - medium: portraitFetch.data.data.attributes.image_style_uri.content_medium, - large: portraitFetch.data.data.attributes.image_style_uri.content_large, + original: portraitFetch.data.data?.attributes.uri.url, + small: portraitFetch.data.data?.attributes.image_style_uri.content_small, + medium: portraitFetch.data.data?.attributes.image_style_uri.content_medium, + large: portraitFetch.data.data?.attributes.image_style_uri.content_large, } : null })) ); return Promise.all(portraitPromises) .then(personnes => ({ - title: item.attributes.title, - weight: item.attributes.field_poid, + title: item.attributes?.title, + weight: item.attributes?.field_poid, personnes })); }) diff --git a/web/themes/custom/caravane/assets/js/vuejs/components/PartenairesContent.vue b/web/themes/custom/caravane/assets/js/vuejs/components/PartenairesContent.vue index 609998a..2c61867 100644 --- a/web/themes/custom/caravane/assets/js/vuejs/components/PartenairesContent.vue +++ b/web/themes/custom/caravane/assets/js/vuejs/components/PartenairesContent.vue @@ -4,13 +4,13 @@