1
- import { cn } from '@repo/utils' ;
2
1
import { type FC } from 'react' ;
2
+ import Link from 'next/link' ;
3
+ import { cn } from '@repo/utils' ;
3
4
import { type PageDataProps } from '../../lib/get-page' ;
4
5
import { Renderers } from './renderers' ;
5
6
import { DocsFooter } from './footer/footer' ;
@@ -8,36 +9,56 @@ import { TableOfContent } from './table-of-content';
8
9
export const Content : FC < { page : PageDataProps } > = ( { page } ) => {
9
10
return (
10
11
< >
11
- < div className = "flex-1 w-full min-w-0 py-12" >
12
+ < div className = "w-full min-w-0 flex-1 py-12" >
12
13
< main className = "mx-auto max-w-[720px]" >
13
14
< h1
14
- className = "relative mt-0 mb-6 text-4xl font-bold text-black transition-colors duration-200 group-hover:text-blue-500 dark:text-white"
15
+ className = "relative mb-6 mt-0 text-4xl font-bold text-black transition-colors duration-200 group-hover:text-blue-500 dark:text-white"
15
16
data-docs-heading
16
17
>
17
18
{ page . title ?? 'Title is missing' }
18
19
</ h1 >
19
20
{ ! page . hideRendererSelector && < Renderers /> }
20
- { /* TODO: Bring back tabs */ }
21
- { /* {page.tabs && page.tabs.length > 0 ? (
22
- <div className="flex items-center gap-8 border-b border-zinc-200">
23
- {page.tabs.map((tab) => {
24
- const isActive = tab.slug === `/docs/${slug?.join('/')}`;
25
-
26
- return (
27
- <Link
28
- className={cn(
21
+ { page . tabs && page . tabs . length > 0 ? (
22
+ < div className = "mb-8 flex items-center gap-8 border-b border-zinc-200" >
23
+ { page . tabs . map ( ( tab ) => {
24
+ const tabTitle = tab . tab ?. title ?? tab . title ;
25
+ const isActive = tab . pathSegment === page . path ;
26
+ const className = cn (
29
27
'-mb-px border-b px-2 pb-2 text-sm capitalize transition-colors hover:text-blue-500' ,
30
28
isActive && 'border-b border-blue-500 text-blue-500' ,
31
- )}
32
- href={tab.slug}
33
- key={tab.name}
34
- >
35
- {tab.tab?.title || tab.title}
36
- </Link>
37
- );
38
- }) }
39
- </div>
40
- ) : null} */ }
29
+ ) ;
30
+
31
+ if ( isActive ) {
32
+ return (
33
+ < span className = { className } key = { tab . name } >
34
+ { tabTitle }
35
+ </ span >
36
+ ) ;
37
+ }
38
+
39
+ const relevantPathSegments = (
40
+ tab . name === 'index.mdx'
41
+ ? tab . pathSegment . split ( '/' ) . slice ( - 2 , - 1 )
42
+ : tab . pathSegment . split ( '/' ) . slice ( - 2 )
43
+ )
44
+ . join ( '/' )
45
+ . replace ( '.mdx' , '' ) ;
46
+ const href = page . isIndexPage
47
+ ? `./${ relevantPathSegments } `
48
+ : `../${ relevantPathSegments } ` ;
49
+
50
+ return (
51
+ < Link
52
+ className = { className }
53
+ href = { href }
54
+ key = { tab . name }
55
+ >
56
+ { tabTitle }
57
+ </ Link >
58
+ ) ;
59
+ } ) }
60
+ </ div >
61
+ ) : null }
41
62
< div
42
63
className = { cn (
43
64
'[&>details]:my-6' ,
0 commit comments