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. * 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 * @returns the layout jsx
*/ */
const DocumentationLayout = ({ const DocumentationLayout = ({

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

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