From 8c9ba24953a50c385c1fc4ea79919ff5428fb36c Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Mon, 12 Feb 2024 12:00:55 -0800 Subject: [PATCH] [F] Event, News, & Related list items have optional featuredImage - Uses `featuredImage` first, `hero` if no `featuredImage`, placeholder image as fallback --- components/dynamic/EventList/index.js | 3 ++- components/dynamic/NewsList/index.js | 7 ++++++- components/dynamic/RelatedList/index.js | 24 +++++++++++++----------- lib/api/fragments/content-blocks.js | 16 +++++++++++++--- lib/api/fragments/event.js | 11 ++++++++--- lib/api/fragments/news-post.js | 11 ++++++++--- 6 files changed, 50 insertions(+), 22 deletions(-) diff --git a/components/dynamic/EventList/index.js b/components/dynamic/EventList/index.js index 6230ac49..62176cd7 100644 --- a/components/dynamic/EventList/index.js +++ b/components/dynamic/EventList/index.js @@ -42,6 +42,7 @@ const EventList = ({ endDate, description, id, + hero, image, eventType, registrationCloseDate, @@ -82,7 +83,7 @@ const EventList = ({ } : null } - image={image?.[0]} + image={image?.[0] || hero?.[0]} link={uri} pretitle={ gridType === "events" && eventType?.[0]?.title diff --git a/components/dynamic/NewsList/index.js b/components/dynamic/NewsList/index.js index e349968d..3d324c3c 100644 --- a/components/dynamic/NewsList/index.js +++ b/components/dynamic/NewsList/index.js @@ -51,6 +51,7 @@ const NewsList = ({ description, subtitle, id, + hero, image, images: releaseImages, newsAssets, @@ -70,7 +71,11 @@ const NewsList = ({ } : null } - image={image?.[0] || makeReleaseFeature(releaseImages)?.[0]} + image={ + image?.[0] || + makeReleaseFeature(releaseImages)?.[0] || + hero?.[0] + } isFeature={canShowFeatured && page === 1 && i === 0} link={uri} pretitle={ diff --git a/components/dynamic/RelatedList/index.js b/components/dynamic/RelatedList/index.js index 4de8c283..b76f95a3 100644 --- a/components/dynamic/RelatedList/index.js +++ b/components/dynamic/RelatedList/index.js @@ -30,17 +30,19 @@ const RelatedList = ({ <> {entries?.length > 0 && ( - {entries.map(({ id, description, image, title, uri }, i) => ( - - ))} + {entries.map( + ({ id, description, hero, image, title, uri }, i) => ( + + ) + )} )} diff --git a/lib/api/fragments/content-blocks.js b/lib/api/fragments/content-blocks.js index d3fa7216..2fe28d0a 100644 --- a/lib/api/fragments/content-blocks.js +++ b/lib/api/fragments/content-blocks.js @@ -342,6 +342,11 @@ export const relatedContentFragment = ` uri ... on pages_pages_Entry { description + hero { + ...on heroes_Asset { + ${getImageFields("crop", 900, 550)} + } + } image: featuredImage { ...on contentImages_Asset { ${getImageFields("crop", 900, 550)} @@ -350,11 +355,16 @@ export const relatedContentFragment = ` } ...on news_post_Entry { description: teaser - image: hero { + hero { ...on heroes_Asset { ${getImageFields("crop", 900, 550)} } } + image: featuredImage { + ...on contentImages_Asset { + ${getImageFields("crop", 900, 550)} + } + } } ...on investigations_investigation_Entry { uri @@ -711,8 +721,8 @@ export const relatedContentNewsFragment = ` ...on news_post_Entry { date description: teaser - image: hero { - ...on heroes_Asset { + image: featuredImage { + ...on contentImages_Asset { ${getImageFields("crop", 900, 550)} } } diff --git a/lib/api/fragments/event.js b/lib/api/fragments/event.js index 09c383ae..0d67b025 100644 --- a/lib/api/fragments/event.js +++ b/lib/api/fragments/event.js @@ -14,11 +14,16 @@ export const eventFragment = ` startDate endDate: date description - image: hero { + hero { ...on heroes_Asset { ${getImageFields("crop", 400, 400)} } } + image: featuredImage { + ...on contentImages_Asset { + ${getImageFields("crop", 400, 400)} + } + } eventType { id title @@ -48,8 +53,8 @@ export const eventFragmentFull = ` ${getImageFields("crop", 1920, 1067)} } } - featuredImage: hero { - ...on heroes_Asset { + featuredImage { + ...on contentImages_Asset { ${getImageFields("crop", 800, 800)} } } diff --git a/lib/api/fragments/news-post.js b/lib/api/fragments/news-post.js index c8039dc7..da14c4e0 100644 --- a/lib/api/fragments/news-post.js +++ b/lib/api/fragments/news-post.js @@ -11,11 +11,16 @@ export const newsPostFragment = ` dateCreated description: teaser pressReleaseId - image: hero { + hero { ...on heroes_Asset { ${getImageFields("crop", 900, 550)} } } + image: featuredImage { + ...on contentImages_Asset { + ${getImageFields("crop", 900, 550)} + } + } postType { id title @@ -58,8 +63,8 @@ export const newsPostFragmentFull = ` } } heroCaption: captionRichText - featuredImage: hero { - ...on heroes_Asset { + featuredImage { + ...on contentImages_Asset { ${getImageFields("crop", 800, 800)} } }