diff --git a/packages/graphics-components/.gitignore b/packages/graphics-components/.gitignore index ba7f352..cd80296 100644 --- a/packages/graphics-components/.gitignore +++ b/packages/graphics-components/.gitignore @@ -192,3 +192,4 @@ dist # End of https://www.toptal.com/developers/gitignore/api/node,macos,linux *storybook.log +storybook-static/ diff --git a/packages/graphics-components/src/components/BlogPost/utils.ts b/packages/graphics-components/src/components/BlogPost/utils.ts index c9bc5d7..7934a0b 100644 --- a/packages/graphics-components/src/components/BlogPost/utils.ts +++ b/packages/graphics-components/src/components/BlogPost/utils.ts @@ -1,7 +1,9 @@ /** * Converts a date string to a short date format. * @param d - The date string to be converted. - * @returns The short date format string. + * @returns The short date format string, or empty string if missing or invalid (avoids throwing on `new Date('').toISOString()`). */ -export const getShortDate = (d: string) => - new Date(d).toISOString().split('T')[0]; +export const getShortDate = (d: string) => { + if (!d || Number.isNaN(Date.parse(d))) return ''; + return new Date(d).toISOString().split('T')[0]; +};