From 4c0dc7f7d9e3948ead94f8fc39be2db54e5aa25f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 2 Dec 2025 11:08:01 +0000 Subject: [PATCH] feat(types): add Props interfaces to 5 blog components Add TypeScript Props interfaces to improve type safety: - Tags.astro: tags and class props - SocialShare.astro: text, url (string|URL), and class props - GridItem.astro: post prop with BlogPost type - ListItem.astro: post prop with BlogPost type - SinglePost.astro: post (with optional body) and url props Also fixed pre-existing issues: - Handle Date|string for datetime attributes via conversion - Handle optional readingTime with nullish coalescing - Support URL type for url props (matches getCanonical return type) - Remove HTML comments from JSX blocks (Prettier compatibility) --- src/components/atoms/SocialShare.astro | 17 +++++--- src/components/atoms/Tags.astro | 7 +++- src/components/blog/GridItem.astro | 35 ++++++++++++---- src/components/blog/ListItem.astro | 57 +++++++++++++++++--------- src/components/blog/SinglePost.astro | 35 +++++++++------- 5 files changed, 101 insertions(+), 50 deletions(-) diff --git a/src/components/atoms/SocialShare.astro b/src/components/atoms/SocialShare.astro index 6ae8980..99035bf 100644 --- a/src/components/atoms/SocialShare.astro +++ b/src/components/atoms/SocialShare.astro @@ -1,23 +1,30 @@ --- import { Icon } from 'astro-icon/components'; + +interface Props { + text?: string; + url?: string | URL; + class?: string; +} + const { text, url, class: className = 'inline-block' } = Astro.props; ---
Share:
diff --git a/src/components/atoms/Tags.astro b/src/components/atoms/Tags.astro index 43fd18f..265b974 100644 --- a/src/components/atoms/Tags.astro +++ b/src/components/atoms/Tags.astro @@ -1,6 +1,11 @@ --- import { getPermalink } from '~/utils/permalinks'; +interface Props { + tags?: string[]; + class?: string; +} + const { tags, class: className = 'text-sm' } = Astro.props; --- @@ -8,7 +13,7 @@ const { tags, class: className = 'text-sm' } = Astro.props; tags && Array.isArray(tags) && (