@@ -4,6 +4,188 @@ import { pluginCallstackTheme } from '@callstack/rspress-theme/plugin';
44import { pluginOpenGraph } from 'rsbuild-plugin-open-graph' ;
55import pluginVercelAnalytics from 'rspress-plugin-vercel-analytics' ;
66
7+ type SidebarItem =
8+ | { text : string ; link : string }
9+ | { text : string ; collapsed ?: boolean ; items : SidebarItem [ ] } ;
10+
11+ // Shared sidebar structure for docs section
12+ const createDocsSidebar = (
13+ version : string ,
14+ extras : { guides ?: string [ ] ; migration ?: SidebarItem [ ] } = { } ,
15+ ) : SidebarItem [ ] => {
16+ const prefix = version ? `/${ version } ` : '' ;
17+ return [
18+ {
19+ text : 'Getting started' ,
20+ items : [
21+ { text : 'Introduction' , link : `${ prefix } /docs/start/intro` } ,
22+ { text : 'Quick Start' , link : `${ prefix } /docs/start/quick-start` } ,
23+ ] ,
24+ } ,
25+ {
26+ text : 'API reference' ,
27+ items : [
28+ { text : 'Render function' , link : `${ prefix } /docs/api/render` } ,
29+ { text : 'Screen object' , link : `${ prefix } /docs/api/screen` } ,
30+ { text : 'Queries' , link : `${ prefix } /docs/api/queries` } ,
31+ { text : 'Jest Matchers' , link : `${ prefix } /docs/api/jest-matchers` } ,
32+ {
33+ text : 'Triggering events' ,
34+ items : [
35+ { text : 'Fire Event' , link : `${ prefix } /docs/api/events/fire-event` } ,
36+ { text : 'User Event' , link : `${ prefix } /docs/api/events/user-event` } ,
37+ ] ,
38+ } ,
39+ {
40+ text : 'Miscellaneous' ,
41+ items : [
42+ { text : 'Accessibility' , link : `${ prefix } /docs/api/misc/accessibility` } ,
43+ { text : 'Async utilities' , link : `${ prefix } /docs/api/misc/async` } ,
44+ { text : 'Config' , link : `${ prefix } /docs/api/misc/config` } ,
45+ { text : 'Other' , link : `${ prefix } /docs/api/misc/other` } ,
46+ { text : 'Render Hook' , link : `${ prefix } /docs/api/misc/render-hook` } ,
47+ ] ,
48+ } ,
49+ ] ,
50+ } ,
51+ {
52+ text : 'Guides' ,
53+ items : [
54+ { text : 'How to Query' , link : `${ prefix } /docs/guides/how-to-query` } ,
55+ ...( extras . guides || [ ] ) . map ( ( g ) => ( {
56+ text : g === 'react-19' ? 'React 19' : g ,
57+ link : `${ prefix } /docs/guides/${ g } ` ,
58+ } ) ) ,
59+ { text : 'Troubleshooting' , link : `${ prefix } /docs/guides/troubleshooting` } ,
60+ { text : 'FAQ' , link : `${ prefix } /docs/guides/faq` } ,
61+ { text : 'Community Resources' , link : `${ prefix } /docs/guides/community-resources` } ,
62+ ] ,
63+ } ,
64+ {
65+ text : 'Advanced Guides' ,
66+ items : [
67+ { text : 'Testing Environment' , link : `${ prefix } /docs/advanced/testing-env` } ,
68+ ...( version !== '12.x' && version !== ''
69+ ? [ { text : 'Third-party Integration' , link : `${ prefix } /docs/advanced/third-party-integration` } ]
70+ : [ ] ) ,
71+ ...( version === ''
72+ ? [ { text : 'Third-party Integration' , link : `${ prefix } /docs/advanced/third-party-integration` } ]
73+ : [ ] ) ,
74+ { text : 'Understanding Act' , link : `${ prefix } /docs/advanced/understanding-act` } ,
75+ ] ,
76+ } ,
77+ {
78+ text : 'Migration Guides' ,
79+ collapsed : true ,
80+ items : extras . migration || [ ] ,
81+ } ,
82+ ] ;
83+ } ;
84+
85+ const createCookbookSidebar = ( version : string , asyncFileName : string ) : SidebarItem [ ] => {
86+ const prefix = version ? `/${ version } ` : '' ;
87+ return [
88+ { text : 'Cookbook' , link : `${ prefix } /cookbook/` } ,
89+ {
90+ text : 'Basic Recipes' ,
91+ items : [
92+ { text : 'Async Tests' , link : `${ prefix } /cookbook/basics/${ asyncFileName } ` } ,
93+ { text : 'Custom Render' , link : `${ prefix } /cookbook/basics/custom-render` } ,
94+ ] ,
95+ } ,
96+ {
97+ text : 'Advanced Recipes' ,
98+ items : [ { text : 'Network Requests' , link : `${ prefix } /cookbook/advanced/network-requests` } ] ,
99+ } ,
100+ {
101+ text : 'State Management Recipes' ,
102+ items : [ { text : 'Jotai' , link : `${ prefix } /cookbook/state-management/jotai` } ] ,
103+ } ,
104+ ] ;
105+ } ;
106+
107+ // Version-specific configurations
108+ const sidebar12x = {
109+ '/12.x/docs/' : createDocsSidebar ( '12.x' , {
110+ migration : [
111+ { text : 'v12 Migration' , link : '/12.x/docs/migration/v12' } ,
112+ { text : 'Jest Matchers' , link : '/12.x/docs/migration/jest-matchers' } ,
113+ {
114+ text : 'Previous versions' ,
115+ collapsed : true ,
116+ items : [
117+ { text : 'v11' , link : '/12.x/docs/migration/previous/v11' } ,
118+ { text : 'v9' , link : '/12.x/docs/migration/previous/v9' } ,
119+ { text : 'v7' , link : '/12.x/docs/migration/previous/v7' } ,
120+ { text : 'v2' , link : '/12.x/docs/migration/previous/v2' } ,
121+ ] ,
122+ } ,
123+ ] ,
124+ } ) ,
125+ '/12.x/cookbook/' : createCookbookSidebar ( '12.x' , 'async-tests' ) ,
126+ } ;
127+
128+ const sidebar13x = {
129+ '/13.x/docs/' : createDocsSidebar ( '13.x' , {
130+ guides : [ 'react-19' ] ,
131+ migration : [
132+ { text : 'v13 Migration' , link : '/13.x/docs/migration/v13' } ,
133+ { text : 'Jest Matchers' , link : '/13.x/docs/migration/jest-matchers' } ,
134+ {
135+ text : 'Previous versions' ,
136+ collapsed : true ,
137+ items : [
138+ { text : 'v12' , link : '/13.x/docs/migration/previous/v12' } ,
139+ { text : 'v11' , link : '/13.x/docs/migration/previous/v11' } ,
140+ { text : 'v9' , link : '/13.x/docs/migration/previous/v9' } ,
141+ { text : 'v7' , link : '/13.x/docs/migration/previous/v7' } ,
142+ { text : 'v2' , link : '/13.x/docs/migration/previous/v2' } ,
143+ ] ,
144+ } ,
145+ ] ,
146+ } ) ,
147+ '/13.x/cookbook/' : createCookbookSidebar ( '13.x' , 'async-tests' ) ,
148+ } ;
149+
150+ const sidebar14x = {
151+ '/14.x/docs/' : createDocsSidebar ( '14.x' , {
152+ migration : [
153+ { text : 'v14 Migration' , link : '/14.x/docs/migration/v14' } ,
154+ { text : 'Jest Matchers' , link : '/14.x/docs/migration/jest-matchers' } ,
155+ { text : 'v13' , link : '/14.x/docs/migration/v13' } ,
156+ { text : 'v12' , link : '/14.x/docs/migration/v12' } ,
157+ { text : 'v11' , link : '/14.x/docs/migration/v11' } ,
158+ { text : 'v9' , link : '/14.x/docs/migration/v9' } ,
159+ { text : 'v7' , link : '/14.x/docs/migration/v7' } ,
160+ { text : 'v2' , link : '/14.x/docs/migration/v2' } ,
161+ ] ,
162+ } ) ,
163+ '/14.x/cookbook/' : createCookbookSidebar ( '14.x' , 'async-events' ) ,
164+ } ;
165+
166+ // Default version (13.x) sidebar without version prefix
167+ const sidebarDefault = {
168+ '/docs/' : createDocsSidebar ( '' , {
169+ guides : [ 'react-19' ] ,
170+ migration : [
171+ { text : 'v13 Migration' , link : '/docs/migration/v13' } ,
172+ { text : 'Jest Matchers' , link : '/docs/migration/jest-matchers' } ,
173+ {
174+ text : 'Previous versions' ,
175+ collapsed : true ,
176+ items : [
177+ { text : 'v12' , link : '/docs/migration/previous/v12' } ,
178+ { text : 'v11' , link : '/docs/migration/previous/v11' } ,
179+ { text : 'v9' , link : '/docs/migration/previous/v9' } ,
180+ { text : 'v7' , link : '/docs/migration/previous/v7' } ,
181+ { text : 'v2' , link : '/docs/migration/previous/v2' } ,
182+ ] ,
183+ } ,
184+ ] ,
185+ } ) ,
186+ '/cookbook/' : createCookbookSidebar ( '' , 'async-tests' ) ,
187+ } ;
188+
7189export default defineConfig ( {
8190 root : 'docs' ,
9191 base : '/react-native-testing-library/' ,
@@ -41,6 +223,20 @@ export default defineConfig({
41223 content : 'https://github.com/callstack/react-native-testing-library' ,
42224 } ,
43225 ] ,
226+ nav : [
227+ { text : 'Docs' , link : '/docs/start/intro' , activeMatch : '^/docs/' } ,
228+ { text : 'Cookbook' , link : '/cookbook/' , activeMatch : '^/cookbook/' } ,
229+ {
230+ text : 'Examples' ,
231+ link : 'https://github.com/callstack/react-native-testing-library/tree/main/examples' ,
232+ } ,
233+ ] ,
234+ sidebar : {
235+ ...sidebarDefault ,
236+ ...sidebar12x ,
237+ ...sidebar13x ,
238+ ...sidebar14x ,
239+ } ,
44240 } ,
45241 builderConfig : {
46242 plugins : [
0 commit comments