display badly filled partenaires

This commit is contained in:
Valentin Le Moign 2025-06-26 15:49:00 +02:00
parent 6f53afa8bf
commit c2174b27c0
2 changed files with 21 additions and 21 deletions

View File

@ -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
}));
})

View File

@ -4,13 +4,13 @@
<p v-html="content.intro"></p>
</div>
<div v-for="partenaire in [...content.partenaires].sort((a, b) => a.weight - b.weight)" class="partenaire">
<figure>
<figure v-if="partenaire.logo_url && partenaire.link_url">
<a :href="partenaire.link_url" target="_blank">
<img :src="partenaire.logo_url.small" :alt="partenaire.logo_alt">
</a>
</figure>
<div class="title"><p v-html="partenaire.title"></p></div>
<div class="description"><p v-html="partenaire.description"></p></div>
<div class="title"><p v-html="partenaire.title || ''"></p></div>
<div class="description"><p v-html="partenaire.description || ''"></p></div>
</div>
</div>
</template>