diff --git a/scripts/buildData.ts b/scripts/buildData.ts index 3d052c8..871f56b 100644 --- a/scripts/buildData.ts +++ b/scripts/buildData.ts @@ -134,7 +134,7 @@ function getUniqueReleases(items: Item[]): string[] { function getUniqueTags(items: Item[]): string[] { const tags = new Set(); for (const item of items) { - for (const tag of item.tags) { + for (const tag of item.tags || []) { tags.add(tag); } } @@ -187,7 +187,7 @@ function postProcessItems(items: Item[]): { // check if config has a key `tags` and if it is an array if (Array.isArray(tags) && tags.length) { // if tags are specified, only keep items that have at least one of the tags - return item.tags.some((tag) => tags.includes(tag)); + return item.tags?.some((tag) => tags.includes(tag)); } return true; @@ -219,6 +219,11 @@ function postProcessItems(items: Item[]): { delete processedItem.revisions; } + // unset tags if there are none + if (!processedItem.tags?.length) { + delete processedItem.tags; + } + return processedItem; }); diff --git a/src/components/ItemDetail/ItemDetail.tsx b/src/components/ItemDetail/ItemDetail.tsx index d2f01bf..a2dcaff 100644 --- a/src/components/ItemDetail/ItemDetail.tsx +++ b/src/components/ItemDetail/ItemDetail.tsx @@ -23,9 +23,7 @@ export function ItemDetail({ item }: ItemProps) { <>

{item.title}

- {item.tags.map((tag) => ( - - ))} + {item.tags?.map((tag) => )}
{notMaintainedText && isNotMaintained(item.release) && ( diff --git a/src/lib/types.ts b/src/lib/types.ts index de5c2b0..99be55a 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -21,7 +21,7 @@ export interface Item { ring: string; quadrant: string; flag: Flag; - tags: string[]; + tags?: string[]; release: Release; revisions?: Revision[]; position: [x: number, y: number]; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index b271d93..38a5f30 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -24,7 +24,7 @@ const Home: CustomPage = () => { const quadrants = getQuadrants(); const tags = getTags(); const items = getItems(undefined, true).filter( - (item) => !tag || item.tags.includes(tag), + (item) => !tag || item.tags?.includes(tag), ); return ( @@ -41,7 +41,7 @@ const Home: CustomPage = () => { rings={rings} items={items} /> - + {tags.length > 0 && } );