Skip to content

Commit 2ecb73f

Browse files
DnzzLclaude
andcommitted
fix: render press release tags as strings on positions page
Press-release tag entities were passed as raw objects to BaseCard's subInfos, which renders each item directly as a React child, throwing "Objects are not valid as a React child". Map tags to their .tag string (blog tags already used .name). Also make the PositionsPageData import type-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7318377 commit 2ecb73f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

frontend/src/app/[locale]/positions/positions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useTranslations } from 'next-intl';
44
import { BaseCardsBlock, LargeTextImage } from '@/components';
55
import Animation from './_partials/Animations';
6-
import { PositionsPageData } from './page';
6+
import type { PositionsPageData } from './page';
77
import { useRef } from 'react';
88
import { getPressReleaseLink } from '@/lib/utils';
99

@@ -17,7 +17,7 @@ function transformPressReleases(press_releases: NonNullable<PositionsPageData['p
1717
tags: [new Date(release.published_date || '').toLocaleString(undefined, { month: 'short', day: 'numeric', year: 'numeric' }), release.media_name],
1818
image: release.thumbnail?.url ?? '/images/dataforgood.svg',
1919
link: getPressReleaseLink(release as { press_release_type: string; article_link: string; article_file: {url: string;}}),
20-
subInfos: release.tags,
20+
subInfos: (release.tags as { tag: string }[] | undefined)?.map((t) => t.tag) ?? [],
2121
isBlank: true,
2222
}))
2323
}
@@ -45,7 +45,7 @@ function transformResources(resources: NonNullable<PositionsPageData['resources'
4545
tags: isBlog ? [new Date(resource.blog?.published_date || '').toLocaleString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })] : [new Date(resource.press_release?.published_date || '').toLocaleString(undefined, { month: 'short', day: 'numeric', year: 'numeric' }), resource.press_release?.media_name],
4646
image: isBlog ? resource.blog?.thumbnail?.url || '/images/dataforgood.svg' : resource.press_release?.thumbnail?.url || "/images/dataforgood.svg",
4747
link: isBlog ? `/blog/${resource.blog?.slug || ''}` : getPressReleaseLink(resource.press_release as { press_release_type: string; article_link: string; article_file: {url: string;}}) || '',
48-
subInfos: isBlog ? (resource.blog as { tags: string[] })?.tags?.map((tag) => tag.name) || [] : (resource.press_release as { tags: string[] })?.tags || [],
48+
subInfos: isBlog ? (resource.blog as { tags: { name: string }[] })?.tags?.map((tag) => tag.name) || [] : (resource.press_release as { tags: { tag: string }[] })?.tags?.map((tag) => tag.tag) || [],
4949
isBlank: true,
5050
}
5151
})

0 commit comments

Comments
 (0)