1
1
'use client' ;
2
2
3
3
import { useBaseOptions } from '@/hooks/useLayoutOptions' ;
4
+ import { parseDocId } from '@/lib/utils' ;
5
+ import {
6
+ NextAppIcon ,
7
+ NextLastedVersionIcon ,
8
+ NextOldVersionIcon ,
9
+ NextPagesIcon ,
10
+ } from '@/mdx/Icon' ;
4
11
import type { PageTree } from 'fumadocs-core/server' ;
12
+ import { RootToggle } from 'fumadocs-ui/components/layout/root-toggle' ;
5
13
import {
6
14
type DocsLayoutProps ,
7
15
DocsLayout as FumaDocsLayout ,
8
- } from 'fumadocs-ui/layouts/docs ' ;
16
+ } from 'fumadocs-ui/layouts/notebook ' ;
9
17
import type { ReactNode } from 'react' ;
10
18
11
19
export function DocsLayout ( {
@@ -18,10 +26,57 @@ export function DocsLayout({
18
26
docId : string ;
19
27
} ) {
20
28
const baseOptions = useBaseOptions ( ) ;
29
+ const { appDocsRoot, pagesDocsRoot, docsRoot } = parseDocId ( docId ) ;
30
+
21
31
const docsLayout : DocsLayoutProps = {
22
32
...baseOptions ,
33
+ links : [ ] ,
23
34
tree : pageTree ,
24
- sidebar : { } ,
35
+ sidebar : {
36
+ banner : (
37
+ < >
38
+ < RootToggle
39
+ options = { [
40
+ {
41
+ title : 'Using App Router' ,
42
+ description : 'Features available in /app' ,
43
+ icon : < NextAppIcon /> ,
44
+ url : appDocsRoot ,
45
+ urls : new Set ( [ docsRoot , appDocsRoot ] ) ,
46
+ } ,
47
+ {
48
+ title : 'Using Pages Router' ,
49
+ description : 'Features available in /pages' ,
50
+ icon : < NextPagesIcon /> ,
51
+ url : pagesDocsRoot ,
52
+ } ,
53
+ ] }
54
+ />
55
+ < RootToggle
56
+ options = { [
57
+ {
58
+ title : 'Using Latest Version' ,
59
+ description : '15.3.2' ,
60
+ icon : < NextLastedVersionIcon /> ,
61
+ url : '/docs/' ,
62
+ } ,
63
+ {
64
+ title : 'Using Version 14' ,
65
+ description : '14.2.29' ,
66
+ icon : < NextOldVersionIcon /> ,
67
+ url : '/docs/14' ,
68
+ } ,
69
+ {
70
+ title : 'Using Version 13' ,
71
+ description : '13.5.11' ,
72
+ icon : < NextOldVersionIcon /> ,
73
+ url : '/docs/13' ,
74
+ } ,
75
+ ] }
76
+ />
77
+ </ >
78
+ ) ,
79
+ } ,
25
80
} ;
26
81
27
82
return < FumaDocsLayout { ...docsLayout } > { children } </ FumaDocsLayout > ;
0 commit comments