From c5e26d83c1862802a51a6e5050ea2b85e5544ddf Mon Sep 17 00:00:00 2001 From: fiatcode Date: Thu, 22 Jan 2026 17:48:29 +0700 Subject: [PATCH] feat: introduce new components for improved structure and functionality --- src/components/BlogPost.astro | 8 ++-- src/components/BlogPostCard.astro | 12 +----- src/components/EmptyState.astro | 9 +++++ src/components/Intro.astro | 67 ++++++++++++++----------------- src/components/PageTitle.astro | 9 +++++ src/components/SocialLink.astro | 17 ++++++++ src/components/Tag.astro | 21 ++++++++++ src/pages/posts/index.astro | 4 +- src/pages/tags/[name].astro | 6 ++- src/pages/tags/index.astro | 10 ++--- 10 files changed, 101 insertions(+), 62 deletions(-) create mode 100644 src/components/EmptyState.astro create mode 100644 src/components/PageTitle.astro create mode 100644 src/components/SocialLink.astro create mode 100644 src/components/Tag.astro diff --git a/src/components/BlogPost.astro b/src/components/BlogPost.astro index 31dbe5e..d32de1d 100644 --- a/src/components/BlogPost.astro +++ b/src/components/BlogPost.astro @@ -1,4 +1,6 @@ --- +import Tag from "@/components/Tag.astro"; + interface Props { title: string; description: string; @@ -41,11 +43,7 @@ const { title, description, date, tags } = Astro.props; { tags?.map((tag) => (
  • - - - #{tag} - - +
  • )) } diff --git a/src/components/BlogPostCard.astro b/src/components/BlogPostCard.astro index 1cedbc5..c3ae70f 100644 --- a/src/components/BlogPostCard.astro +++ b/src/components/BlogPostCard.astro @@ -4,10 +4,9 @@ interface Props { date: Date; title: string; description: string; - tags?: string[]; } -const { id, date, title, description, tags } = Astro.props; +const { id, date, title, description } = Astro.props; --- @@ -22,13 +21,6 @@ const { id, date, title, description, tags } = Astro.props; }

    {title}

    -

    {description}

    -
    - { - tags?.map((tag) => ( - #{tag} - )) - } -
    +

    {description}

    diff --git a/src/components/EmptyState.astro b/src/components/EmptyState.astro new file mode 100644 index 0000000..5221dfa --- /dev/null +++ b/src/components/EmptyState.astro @@ -0,0 +1,9 @@ +--- +interface Props { + message: string; +} + +const { message } = Astro.props; +--- + +

    {message}

    diff --git a/src/components/Intro.astro b/src/components/Intro.astro index 11a7166..bdf25a7 100644 --- a/src/components/Intro.astro +++ b/src/components/Intro.astro @@ -6,6 +6,7 @@ import socialFacebook from "@/assets/images/social-facebook.svg"; import socialGithub from "@/assets/images/social-github.svg"; import socialLinkedIn from "@/assets/images/social-linkedin.svg"; import socialX from "@/assets/images/social-x.svg"; +import SocialLink from "@/components/SocialLink.astro"; ---
    @@ -18,44 +19,36 @@ import socialX from "@/assets/images/social-x.svg";

    Dhemas Nurjaya

    Passionate Software Engineer

    - - LinkedIn - - - Github - - - X - - - Facebook - - - Email - + label="Linkedin" + icon={socialLinkedIn} + alt="LinkedIn" + /> + + + +
    diff --git a/src/components/PageTitle.astro b/src/components/PageTitle.astro new file mode 100644 index 0000000..8368863 --- /dev/null +++ b/src/components/PageTitle.astro @@ -0,0 +1,9 @@ +--- +interface Props { + title: string; +} + +const { title } = Astro.props; +--- + +

    {title}

    diff --git a/src/components/SocialLink.astro b/src/components/SocialLink.astro new file mode 100644 index 0000000..d8716e8 --- /dev/null +++ b/src/components/SocialLink.astro @@ -0,0 +1,17 @@ +--- +import { Image } from "astro:assets"; +import type { ImageMetadata } from "astro"; + +interface Props { + href: string; + label: string; + icon: ImageMetadata; + alt: string; +} + +const { href, label, icon, alt } = Astro.props; +--- + + + {alt} + diff --git a/src/components/Tag.astro b/src/components/Tag.astro new file mode 100644 index 0000000..1a26f22 --- /dev/null +++ b/src/components/Tag.astro @@ -0,0 +1,21 @@ +--- +interface Props { + name: string; + count?: number; + href?: string; + variant?: "default" | "small"; +} + +const { name, count, href, variant = "default" } = Astro.props; +const linkHref = href || `/tags/${name}`; +const isSmall = variant === "small"; +const textSize = isSmall ? "text-xs" : "text-sm"; +--- + + + + #{name}{count !== undefined && {count}} + + diff --git a/src/pages/posts/index.astro b/src/pages/posts/index.astro index 9b4a374..bb44ca1 100644 --- a/src/pages/posts/index.astro +++ b/src/pages/posts/index.astro @@ -2,6 +2,7 @@ import { getCollection } from "astro:content"; import Layout from "@/layouts/Layout.astro"; import BlogPostCard from "@/components/BlogPostCard.astro"; +import PageTitle from "@/components/PageTitle.astro"; const posts = await getCollection("blog"); posts.sort((a, b) => b.data.date.getTime() - a.data.date.getTime()); @@ -11,7 +12,7 @@ posts.sort((a, b) => b.data.date.getTime() - a.data.date.getTime()); title="Posts - Dhemas Nurjaya" description="Read the latest blog posts by Dhemas Nurjaya" > -

    Posts

    +