Skip to content

Commit

Permalink
[F] Event, News, & Related list items have optional featuredImage
Browse files Browse the repository at this point in the history
 - Uses `featuredImage` first, `hero` if no `featuredImage`, placeholder image as fallback
  • Loading branch information
Blake Mason authored and blnkt committed Mar 6, 2024
1 parent 6963895 commit 8c9ba24
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 22 deletions.
3 changes: 2 additions & 1 deletion components/dynamic/EventList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const EventList = ({
endDate,
description,
id,
hero,
image,
eventType,
registrationCloseDate,
Expand Down Expand Up @@ -82,7 +83,7 @@ const EventList = ({
}
: null
}
image={image?.[0]}
image={image?.[0] || hero?.[0]}
link={uri}
pretitle={
gridType === "events" && eventType?.[0]?.title
Expand Down
7 changes: 6 additions & 1 deletion components/dynamic/NewsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const NewsList = ({
description,
subtitle,
id,
hero,
image,
images: releaseImages,
newsAssets,
Expand All @@ -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={
Expand Down
24 changes: 13 additions & 11 deletions components/dynamic/RelatedList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ const RelatedList = ({
<>
{entries?.length > 0 && (
<Grid columns={cols}>
{entries.map(({ id, description, image, title, uri }, i) => (
<Tile
key={id}
image={image?.[0]}
link={uri}
text={striptags(description)}
title={title}
titleTag={"h2"}
type={gridType}
/>
))}
{entries.map(
({ id, description, hero, image, title, uri }, i) => (
<Tile
key={id}
image={image?.[0] || hero?.[0]}
link={uri}
text={striptags(description)}
title={title}
titleTag={"h2"}
type={gridType}
/>
)
)}
</Grid>
)}
</>
Expand Down
16 changes: 13 additions & 3 deletions lib/api/fragments/content-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -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
Expand Down Expand Up @@ -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)}
}
}
Expand Down
11 changes: 8 additions & 3 deletions lib/api/fragments/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,8 +53,8 @@ export const eventFragmentFull = `
${getImageFields("crop", 1920, 1067)}
}
}
featuredImage: hero {
...on heroes_Asset {
featuredImage {
...on contentImages_Asset {
${getImageFields("crop", 800, 800)}
}
}
Expand Down
11 changes: 8 additions & 3 deletions lib/api/fragments/news-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -58,8 +63,8 @@ export const newsPostFragmentFull = `
}
}
heroCaption: captionRichText
featuredImage: hero {
...on heroes_Asset {
featuredImage {
...on contentImages_Asset {
${getImageFields("crop", 800, 800)}
}
}
Expand Down

0 comments on commit 8c9ba24

Please sign in to comment.