Skip to content
8 changes: 6 additions & 2 deletions src/components/Nav/MainNavLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type MainNavLinksProps = {
hasJumpTo: boolean;
handleToggle: () => void;
isOpen: boolean;
currentPath: string;
};

export const MainNavLinks = ({
Expand All @@ -25,6 +26,7 @@ export const MainNavLinks = ({
handleToggle,
isOpen,
hasJumpTo,
currentPath,
}: MainNavLinksProps) => {
if (!links || links?.length <= 0) return null;

Expand Down Expand Up @@ -74,8 +76,10 @@ export const MainNavLinks = ({
{renderLogo()}
<ul>
{links.map((link) => (
<li key={link.label}>
<a href={link.url}>{link.label}</a>
<li key={link.label} class={styles.linklabel}>
<a href={link.url} class={currentPath === link.url ? "current" : ""}>
{link.label}
</a>
</li>
))}
</ul>
Expand Down
3 changes: 3 additions & 0 deletions src/components/Nav/NavPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface NavPanelsProps {
jumpToLabel: string;
isHomepage: boolean;
jumpToState: JumpToState | null;
currentPath: string;
}

/**
Expand All @@ -30,6 +31,7 @@ export const NavPanels = (props: NavPanelsProps) => {
mobileMenuLabel,
jumpToLabel,
jumpToState,
currentPath,
} = props;

const [isOpen, setIsOpen] = useState({ main: false, jump: false });
Expand Down Expand Up @@ -90,6 +92,7 @@ export const NavPanels = (props: NavPanelsProps) => {
hasJumpTo={jumpToState !== null}
isOpen={isOpen.main}
handleToggle={handleMainNavToggle}
currentPath={currentPath}
/>
<JumpToLinks
heading={jumpToState?.heading || jumpToLabel}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Nav/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const mainLinks = [
{ url: "/about/", label: t("About") },
] as { url: string; label: string }[];

const currentPath = mainLinks.find((link) => pathMinusLocale.startsWith(link.url))?.url ?? "";

const editorButtonLabel = t("Start Coding");
const donateButtonLabel = t("Donate");
const mobileMenuLabel = t("Menu");
Expand All @@ -37,6 +39,7 @@ const jumpToLabel = t("Jump To");
mobileMenuLabel={mobileMenuLabel as string}
jumpToLabel={jumpToLabel as string}
jumpToState={jumpToState}
currentPath={currentPath}
client:load
/>
</nav>
Loading