From 5e2a3f88b989b1795b287a6b731402ce41eb41e2 Mon Sep 17 00:00:00 2001 From: Emil Gulamov <125820963+mearashadowfax@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:16:21 +0400 Subject: [PATCH] Add NavLink component for navbar This commit introduces a reusable NavLink component for the navigation bar. This component has a script to highlight the active link by comparing the current URL with each link's href. It also improves code readability by separating concerns. --- src/components/Navbar.astro | 119 +++++++++++++++----------- src/components/ui/links/NavLink.astro | 40 +++++++++ 2 files changed, 109 insertions(+), 50 deletions(-) create mode 100644 src/components/ui/links/NavLink.astro diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index 927e08d..c3435d8 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -1,12 +1,13 @@ --- -import ThemeIcon from "../components/ThemeIcon.astro"; +import ThemeIcon from "./ThemeIcon.astro"; +import NavLink from "./ui/links/NavLink.astro"; ---
@@ -239,4 +258,4 @@ import ThemeIcon from "../components/ThemeIcon.astro"; }); }); }); - \ No newline at end of file + diff --git a/src/components/ui/links/NavLink.astro b/src/components/ui/links/NavLink.astro new file mode 100644 index 0000000..ca76e07 --- /dev/null +++ b/src/components/ui/links/NavLink.astro @@ -0,0 +1,40 @@ +--- +const { url, name } = Astro.props; + +interface Props { + url: string; + name: string; +} +--- + + + {name} + + +