Fix the docs sidebar active link status not properly working
All checks were successful
Deploy Frontend / docker (17, 3.8.5) (push) Successful in 1m1s

This commit is contained in:
Braydon 2024-04-21 13:45:26 -04:00
parent 3ea7e8c70e
commit 335ed10a53
3 changed files with 28 additions and 19 deletions

@ -9,7 +9,8 @@ export const dynamic = "force-static";
/**
* The layout for the docs page.
*
* @param children the children of this layout
* @param params the params of the request
* @param render the children to render
* @returns the layout jsx
*/
const DocumentationLayout = ({

@ -20,7 +20,7 @@ import Image from "next/image";
* The page to display content
* from an MDX file on the docs.
*
* @param slug the slug of the mdx file
* @param params the params of the request
* @return the page jsx
*/
const ContentPage = ({ params }: PageProps): ReactElement => {

@ -55,23 +55,31 @@ const Sidebar = ({ activeSlug }: { activeSlug: string }): ReactElement => {
{/* Links */}
<div className="flex flex-col border-l border-zinc-700">
{categoryContent.map(
(content, contentIndex) => (
<Link
key={contentIndex}
className={cn(
"pl-3 -ml-px text-zinc-200 hover:opacity-85 transition-all transform-gpu",
activeSlug ===
content.slug &&
"border-l border-minecraft-green-4"
)}
href={
`/docs/${content.slug}` ||
"#"
}
>
{content.title}
</Link>
)
(
content: DocsContentMetadata,
contentIndex: number
): ReactElement => {
const active: boolean =
(!activeSlug &&
content.slug === "home") ||
activeSlug === content.slug;
return (
<Link
key={contentIndex}
className={cn(
"pl-3 -ml-px text-zinc-200 hover:opacity-85 transition-all transform-gpu",
active &&
"border-l border-minecraft-green-4"
)}
href={
`/docs/${content.slug}` ||
"#"
}
>
{content.title}
</Link>
);
}
)}
</div>
</div>