Skip to content

Commit

Permalink
fix: press release related items missing images
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgoff committed Sep 19, 2024
1 parent a34e564 commit fd05b6a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
49 changes: 24 additions & 25 deletions components/content-blocks/GridBlock/CarouselGrid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ import chunk from "lodash/chunk";
import Tile from "@/atomic/Tile";
import Loader from "@/atomic/Loader";
import { Grid } from "@rubin-epo/epo-react-lib";
import { useReleases } from "@/lib/api/noirlabReleases";
import { normalizeItemData, makeReleaseFeature, useList } from "@/lib/utils";
import * as Styled from "./styles";

function CarouselGrid({
items = [],
limit,
listTypeId,
sectionHandle,
pageId,
}) {
function CarouselGrid({ items = [], limit, listTypeId, pageId }) {
const section = "pages";
const tileType = "pages";
// get manually-curated data first
const curatedItems = normalizeItemData(items);
const { entries } = useReleases("default", curatedItems);

const { data, isLoading } = useList({
limit,
Expand All @@ -28,12 +24,13 @@ function CarouselGrid({
}) || {
data: {},
};

const curatedIds = curatedItems.map((item) => item.id);
// filter out curatedItems
const filteredEntries = !data?.entries?.length
? []
: data.entries.filter((item) => curatedIds.indexOf(item.id) < 0);
const allItems = [...curatedItems, ...filteredEntries];
const allItems = [...entries, ...filteredEntries];
const chunkedItems = chunk(allItems, 3);

function renderTiles(renderedItems) {
Expand All @@ -50,24 +47,26 @@ function CarouselGrid({
externalUrl,
uri,
landingPage,
}) => (
<Tile
key={id}
image={
image?.[0] ||
makeReleaseFeature(releaseImages, "screen640")?.[0] ||
hero?.[0]
}
link={
mixedLink || {
url: externalUrl || uri || landingPage?.[0]?.uri,
}) => {
return (
<Tile
key={id}
image={
image?.[0] ||
makeReleaseFeature(releaseImages, "screen640")?.[0] ||
hero?.[0]
}
link={
mixedLink || {
url: externalUrl || uri || landingPage?.[0]?.uri,
}
}
}
text={plainText || striptags(description)}
title={title}
type={tileType}
/>
)
text={plainText || striptags(description)}
title={title}
type={tileType}
/>
);
}
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/api/fragments/content-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ export const relatedContentFragment = `
}
}
...on news_post_Entry {
pressReleaseId
description: teaser
hero {
...on heroes_Asset {
Expand Down

0 comments on commit fd05b6a

Please sign in to comment.