diff --git a/apps/frontpage/components/docs/content.tsx b/apps/frontpage/components/docs/content.tsx index bb066f47..b22e2ef7 100644 --- a/apps/frontpage/components/docs/content.tsx +++ b/apps/frontpage/components/docs/content.tsx @@ -1,5 +1,6 @@ -import { cn } from '@repo/utils'; import { type FC } from 'react'; +import Link from 'next/link'; +import { cn } from '@repo/utils'; import { type PageDataProps } from '../../lib/get-page'; import { Renderers } from './renderers'; import { DocsFooter } from './footer/footer'; @@ -8,36 +9,56 @@ import { TableOfContent } from './table-of-content'; export const Content: FC<{ page: PageDataProps }> = ({ page }) => { return ( <> -
+

{page.title ?? 'Title is missing'}

{!page.hideRendererSelector && } - {/* TODO: Bring back tabs */} - {/* {page.tabs && page.tabs.length > 0 ? ( -
- {page.tabs.map((tab) => { - const isActive = tab.slug === `/docs/${slug?.join('/')}`; - - return ( - 0 ? ( +
+ {page.tabs.map((tab) => { + const tabTitle = tab.sidebar?.title ?? tab.title; + const isActive = tab.pathSegment === page.path; + const className = cn( '-mb-px border-b px-2 pb-2 text-sm capitalize transition-colors hover:text-blue-500', isActive && 'border-b border-blue-500 text-blue-500', - )} - href={tab.slug} - key={tab.name} - > - {tab.tab?.title || tab.title} - - ); - })} -
- ) : null} */} + ); + + if (isActive) { + return ( + + {tabTitle} + + ); + } + + const relevantPathSegments = ( + tab.name === 'index.mdx' + ? tab.pathSegment.split('/').slice(-2, -1) + : tab.pathSegment.split('/').slice(-2) + ) + .join('/') + .replace('.mdx', ''); + const href = page.isIndexPage + ? `./${relevantPathSegments}` + : `../${relevantPathSegments}`; + + return ( + + {tabTitle} + + ); + })} +
+ ) : null}
details]:my-6', diff --git a/apps/frontpage/lib/get-page.tsx b/apps/frontpage/lib/get-page.tsx index 3fbf1c77..2f652d7a 100644 --- a/apps/frontpage/lib/get-page.tsx +++ b/apps/frontpage/lib/get-page.tsx @@ -23,6 +23,7 @@ export interface PageDataProps { isIndexPage: boolean; tabs: RawTreeProps[]; content: ReactElement; + path: string; } export const getPageData = async ( @@ -109,6 +110,7 @@ export const getPageData = async ( return { ...frontmatter, isIndexPage: isIndexMDX || isIndexMD, + path: newPath, tabs: index?.isTab ? parent : [], content, };