Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
22 changes: 22 additions & 0 deletions src/components/Nav/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ const mainLinks = [
{ url: "/about/", label: t("About") },
] as { url: string; label: string }[];

// Define which paths should trigger an underline for a parent section
const unmatchedPathMappings: Record<string, string> = {
"/events/": "/community/",
"/sketches/": "/community/",
"/libraries/": "/community/",
"/people/": "/about/",
"/code-of-conduct/": "/about/",
"/education-resources/": "/tutorials/",
"/donate/": "/contribute/"
};

// Check if the current URL matches the extra triggers
const extraPathTriggers = Object.keys(unmatchedPathMappings).find(trigger =>
pathMinusLocale.startsWith(trigger)
);

// Set the active path: use the mapping if found, otherwise fall back to the main links logic
const currentPath = extraPathTriggers
? unmatchedPathMappings[extraPathTriggers]
: (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 +58,7 @@ const jumpToLabel = t("Jump To");
mobileMenuLabel={mobileMenuLabel as string}
jumpToLabel={jumpToLabel as string}
jumpToState={jumpToState}
currentPath={currentPath}
client:load
/>
</nav>