From f1bb6bc52f8e5b2ccd54ba7c5a36f2359628f83c Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Thu, 12 Jun 2025 22:27:42 +0200 Subject: Extract NameLink --- src/components/NameLink.astro | 42 +++++++++++++++++++++++++++++ src/pages/index.astro | 63 ++++++++++--------------------------------- 2 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 src/components/NameLink.astro diff --git a/src/components/NameLink.astro b/src/components/NameLink.astro new file mode 100644 index 0000000..8ceb7e1 --- /dev/null +++ b/src/components/NameLink.astro @@ -0,0 +1,42 @@ +--- +interface Props { + name: { + data: { + name: string; + domain: string; + url?: string; + candidate?: boolean; + }; + }; + size?: 'large' | 'small'; +} + +const { name, size = 'large' } = Astro.props; +const nameParts = name.data.name.toLowerCase().split(" "); +const domain = name.data.domain.replace(".", ""); +const url = name.data.url || `https://${name.data.domain}`; + +const sizeClasses = { + large: 'text-2xl', + small: 'text-xl' +}; +--- + + + {nameParts.map((part, index) => ( + <> + {index > 0 && " "} + {part === domain ? ( + + {name.data.domain} + + ) : ( + {part} + )} + > + ))} + \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index 1981ec1..9dfc1ee 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,5 +1,6 @@ --- import { getCollection } from "astro:content"; +import NameLink from "../components/NameLink.astro"; import "../styles/global.css"; @@ -34,59 +35,23 @@ const candidates = allNames.filter(name => name.data.candidate === true);