From 06fce5508a7c31f668868b1aecb13079d5c8f2fe Mon Sep 17 00:00:00 2001 From: Graham Hall Date: Sun, 18 Feb 2024 19:23:55 -0500 Subject: [PATCH] adding prop types --- src/components/Header.astro | 7 ++++++- src/components/PostPreview.astro | 11 ++++++++++- src/components/Tags.astro | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/Header.astro b/src/components/Header.astro index bebceb5..7d7bc7d 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,7 +1,12 @@ --- const { pathname } = Astro.url; -const navLinks = [ +type NavLink = { + label: string; + path: string; +}; + +const navLinks: NavLink[] = [ { label: '📝 Blog', path: '/' }, { label: '👤 About', path: '/about/' }, ]; diff --git a/src/components/PostPreview.astro b/src/components/PostPreview.astro index e3c2e3e..6b22451 100644 --- a/src/components/PostPreview.astro +++ b/src/components/PostPreview.astro @@ -2,8 +2,17 @@ import BlogHeader from '@components/BlogHeader.astro'; import Tags from '@components/Tags.astro'; +interface Post { + data: { + title: string; + pubDate: Date; + tags: string[]; + }; + slug: string; +} + interface Props { - post: Object; + post: Post; } const { post } = Astro.props; diff --git a/src/components/Tags.astro b/src/components/Tags.astro index 1882f70..32f90d8 100644 --- a/src/components/Tags.astro +++ b/src/components/Tags.astro @@ -1,4 +1,8 @@ --- +interface Props { + tags: string[]; +} + const { tags } = Astro.props; ---