{page.title ?? 'Title is missing'}
{!page.hideRendererSelector &&
- {page.tabs.map((tab) => {
- const isActive = tab.slug === `/docs/${slug?.join('/')}`;
-
- return (
- 0 ? (
+
+ ) : null}
+ {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}
+
+ );
+ })}
+ 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,
};