@lukoweb/apitogo 0.2.46 → 0.2.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,421 +1,415 @@
1
- ---
2
- title: Navigation
3
- sidebar_icon: compass
4
- description:
5
- Learn how to configure the navigation in APIToGo, including links, categories, documents, and
6
- custom pages. Understand the structure of the navigation array and how to use icons, labels, and
7
- paths.
8
- ---
9
-
10
- import { Book, Code, FileText } from "@lukoweb/apitogo/icons";
11
-
12
- APIToGo uses a single `navigation` array to control both the top navigation tabs and the sidebar.
13
- Items at the root of this array appear as tabs, and nested items build the sidebar tree. Navigation
14
- entries can be links, document references, categories or custom pages.
15
-
16
- ## Basic configuration
17
-
18
- The navigation is defined using the `navigation` array in the APIToGo config file. Each item can be
19
- one of several types. At the simplest level you may only have links and categories.
20
-
21
- ```tsx title="config"
22
- {
23
- "navigation": [
24
- {
25
- "type": "category",
26
- "label": "Documentation",
27
- "icon": "book",
28
- "items": [
29
- {
30
- "type": "doc",
31
- "file": "documentation/introduction",
32
- "label": "Introduction",
33
- "icon": "file-text"
34
- },
35
- {
36
- "type": "doc",
37
- "file": "documentation/getting-started",
38
- "path": "/docs/quick-start",
39
- "label": "Quick Start"
40
- }
41
- ]
42
- },
43
- {
44
- "type": "link",
45
- "to": "/api",
46
- "label": "API Reference",
47
- "icon": "code",
48
- "description": "Complete API documentation",
49
- "badge": {
50
- "label": "v2.0",
51
- "color": "blue"
52
- },
53
- "display": "always"
54
- }
55
- ]
56
- }
57
- ```
58
-
59
- ## Generate navigation automatically
60
-
61
- Use the CLI command **`npx apitogo config`** to merge **`navigation`** from your pages folder into
62
- `apitogo.config.json`. See **[Make config (CLI)](./make-config.md)** for usage. The command does
63
- **not** change **`redirects`**.
64
-
65
- ::::caution
66
-
67
- Without `--force`, `npx apitogo config` only **adds missing** Documentation items. `--force`
68
- rebuilds Documentation items from disk but still keeps other nav entries such as API Reference.
69
-
70
- ::::
71
-
72
- ## Navigation Items
73
-
74
- Navigation items can be of these types: `category`, `doc`, `link`, or `custom-page`.
75
-
76
- - `link`: A direct link to a page or external URL.
77
- - `category`: A group of links that can be expanded or collapsed.
78
- - `doc`: A reference to a document by it's file path: `file`.
79
- - `custom-pages`: A custom page that is made of a React component, see
80
- [Custom Pages](../guides/custom-pages.md)
81
-
82
- ### `type: link`
83
-
84
- `link` is the most basic item, it directly links to a path or URL. Use this for external resources
85
- or standalone pages.
86
-
87
- ```json
88
- {
89
- "type": "link",
90
- "label": "Support",
91
- "to": "/my/api" // or: https://example.com/my-external-link
92
- }
93
- ```
94
-
95
- <details>
96
- <summary>**TypeScript type declaration**</summary>
97
- ```ts
98
- type NavigationLink = {
99
- type: "link";
100
- to: string;
101
- label: string;
102
- icon?: string; // Lucide icon name
103
- description?: string;
104
- badge?: {
105
- label: string;
106
- color: "green" | "blue" | "yellow" | "red" | "purple" | "indigo" | "gray" | "outline";
107
- };
108
- display?:
109
- | "auth"
110
- | "anon"
111
- | "always"
112
- | "hide"
113
- | ((params: { context: ApitogoContext; auth: UseAuthReturn }) => boolean);
114
- target?: "_self" | "_blank";
115
- };
116
- ```
117
- </details>
118
-
119
- ### `type: category`
120
-
121
- The `category` type groups related items under a collapsible section. The `label` is the displayed
122
- text, and the `items` array contains `id`s of documents, links, or other categories.
123
-
124
- ```json
125
- {
126
- "type": "category",
127
- "label": "Getting Started",
128
- "collapsible": true, // optional
129
- "collapsed": false, // optional
130
- "items": [
131
- {
132
- "type": "link",
133
- "label": "Support",
134
- "to": "https://support.example.com"
135
- }
136
- ]
137
- }
138
- ```
139
-
140
- <details>
141
- <summary>**TypeScript type declaration**</summary>
142
-
143
- ```ts
144
- type NavigationCategory = {
145
- type: "category";
146
- icon?: string; // Lucide icon name
147
- items: Array<NavigationDoc | NavigationLink | NavigationCategory | NavigationCustomPage>;
148
- label: string;
149
- collapsible?: boolean;
150
- collapsed?: boolean;
151
- link?: string | { type: "doc"; file: string; label?: string };
152
- display?:
153
- | "auth"
154
- | "anon"
155
- | "always"
156
- | "hide"
157
- | ((params: { context: ApitogoContext; auth: UseAuthReturn }) => boolean);
158
- };
159
- ```
160
-
161
- </details>
162
-
163
- ### `type: doc`
164
-
165
- Doc is used to reference markdown files. The `label` is the text that will be displayed, and the
166
- `file` is the file path associated with a markdown file.
167
-
168
- ```json
169
- {
170
- "type": "doc",
171
- "label": "Overview",
172
- "file": "docs/overview"
173
- }
174
- ```
175
-
176
- <details>
177
- <summary>**TypeScript type declaration**</summary>
178
-
179
- ```ts
180
- type NavigationDoc = {
181
- type: "doc";
182
- file: string;
183
- path?: string;
184
- icon?: string;
185
- label?: string;
186
- badge?: {
187
- label: string;
188
- color: "green" | "blue" | "yellow" | "red" | "purple" | "indigo" | "gray" | "outline";
189
- };
190
- display?:
191
- | "auth"
192
- | "anon"
193
- | "always"
194
- | "hide"
195
- | ((params: { context: ApitogoContext; auth: UseAuthReturn }) => boolean);
196
- };
197
- ```
198
-
199
- </details>
200
-
201
- #### Using shorthands
202
-
203
- Documents can be referenced as strings (using their file path), which is equivalent to
204
- `{ "type": "doc", "file": "path" }`:
205
-
206
- ```json
207
- {
208
- "navigation": [
209
- {
210
- "type": "category",
211
- "label": "Documentation",
212
- "icon": "book",
213
- "items": [
214
- "documentation/introduction",
215
- "documentation/getting-started",
216
- "documentation/installation"
217
- ]
218
- },
219
- {
220
- "type": "link",
221
- "to": "/api",
222
- "label": "API Reference",
223
- "icon": "code"
224
- }
225
- ]
226
- }
227
- ```
228
-
229
- This is much more concise when you don't need custom labels, icons, or other properties for
230
- individual documents.
231
-
232
- Learn more in the [Markdown documentation](/docs/markdown/overview)
233
-
234
- #### Custom paths
235
-
236
- The `path` property allows you to customize the URL path for a document. By default, APIToGo uses
237
- the file path to generate the URL, but you can override this behavior by specifying a custom path.
238
-
239
- ### `type: custom-page`
240
-
241
- Custom pages allow you to create standalone pages that are not tied to a Markdown document. This is
242
- useful for creating landing pages, dashboards, or any other custom content.
243
-
244
- ```tsx
245
- {
246
- type: "custom-page",
247
- path: "/a-custom-page",
248
- element: <MyCustomPage />,
249
- display: "always"
250
- }
251
- ```
252
-
253
- <details>
254
- <summary>**TypeScript type declaration**</summary>
255
-
256
- ```ts
257
- type NavigationCustomPage = {
258
- type: "custom-page";
259
- path: string;
260
- label?: string;
261
- element: any;
262
- icon?: string; // Lucide icon name
263
- badge?: {
264
- label: string;
265
- color: "green" | "blue" | "yellow" | "red" | "purple" | "indigo" | "gray" | "outline";
266
- invert?: boolean;
267
- };
268
- display?:
269
- | "auth"
270
- | "anon"
271
- | "always"
272
- | "hide"
273
- | ((params: { context: ApitogoContext; auth: UseAuthReturn }) => boolean);
274
- };
275
- ```
276
-
277
- </details>
278
-
279
- ## Display Control
280
-
281
- All navigation items support a `display` property that controls when the item should be visible:
282
-
283
- - `"always"` (default): Always visible
284
- - `"auth"`: Only visible when user is authenticated
285
- - `"anon"`: Only visible when user is not authenticated
286
- - `"hide"`: Never visible (useful for temporarily hiding items)
287
- - **callback function**: For custom logic, pass a function that receives `{ context, auth }` and
288
- returns a boolean
289
-
290
- ```json
291
- {
292
- "type": "link",
293
- "label": "Admin Panel",
294
- "to": "/admin",
295
- "display": "auth"
296
- }
297
- ```
298
-
299
- ### Custom Display Logic
300
-
301
- For more complex visibility rules, use a callback function:
302
-
303
- ```tsx
304
- {
305
- type: "link",
306
- label: "Premium Features",
307
- to: "/premium",
308
- display: ({ auth }) => {
309
- // Show only for users with premium role
310
- return auth.user?.role === "premium";
311
- }
312
- }
313
- ```
314
-
315
- The callback receives:
316
-
317
- - `context`: The APIToGo runtime context (TypeScript type: `ApitogoContext`)
318
- - `auth`: The authentication state from `UseAuthReturn`, including `user`, `isAuthenticated`, etc.
319
-
320
- ## Badges
321
-
322
- Navigation items can display badges with labels and colors. Badges support an optional `invert`
323
- property for styling:
324
-
325
- ```json
326
- {
327
- "type": "doc",
328
- "file": "api/v2",
329
- "badge": {
330
- "label": "Beta",
331
- "color": "yellow"
332
- }
333
- }
334
- ```
335
-
336
- ## Icons
337
-
338
- Icons can be added to categories and documents by specifying an `icon` property. The value should be
339
- the name of a [Lucide icon](https://lucide.dev/icons) (e.g., `book` <Book size={16}
340
- style={{ display: 'inline' }} />, `code` <Code size={16} style={{ display: 'inline' }} />,
341
- `file-text` <FileText size={16} style={{ display: 'inline' }} />).
342
-
343
- ```json
344
- {
345
- "type": "category",
346
- "label": "Getting Started",
347
- "icon": "book"
348
- }
349
- ```
350
-
351
- They can also be set on individual documents in their front matter:
352
-
353
- ```md
354
- ---
355
- title: My Document
356
- sidebar_icon: book
357
- ---
358
- ```
359
-
360
- ## Title & Labels
361
-
362
- All navigation items can have a `label` property that determines the displayed text. For `doc`
363
- items, the `label` is optional; if omitted, APIToGo uses the document's `title` from its front
364
- matter or the first `#` header.
365
-
366
- To override the navigation label without changing the document's `title`, use the `sidebar_label`
367
- property in the front matter:
368
-
369
- ```md
370
- ---
371
- title: My Long Title
372
- sidebar_label: Short Title
373
- ---
374
- ```
375
-
376
- In this example, the document's title remains "My Long Title," but the sidebar displays "Short
377
- Title."
378
-
379
- ## Navigation Rules
380
-
381
- Plugins generate sidebar navigation automatically (e.g. from OpenAPI tags). Navigation rules let you
382
- customize that generated sidebar by inserting, modifying, sorting, moving, or removing items. To
383
- change the top-level tabs themselves, use the `navigation` array directly.
384
-
385
- ```tsx
386
- navigationRules: [
387
- {
388
- type: "sort",
389
- match: "Shipments",
390
- by: (a, b) => a.label.localeCompare(b.label),
391
- },
392
- ],
393
- ```
394
-
395
- For a practical walkthrough with more examples, see the
396
- [Navigation Rules](/docs/guides/navigation-rules) guide.
397
-
398
- ### Rule Types
399
-
400
- Each rule has a `type` and a `match` property that targets a navigation item.
401
-
402
- | Type | Description |
403
- | -------- | ------------------------------------------------------------------------- |
404
- | `insert` | Add items `before` or `after` a matched item |
405
- | `modify` | Change `label`, `icon`, `badge`, `collapsed`, `collapsible`, or `display` |
406
- | `remove` | Remove a matched item from the sidebar |
407
- | `sort` | Sort children of a matched category using a custom comparator |
408
- | `move` | Relocate a matched item `before` or `after` another item |
409
-
410
- ### Match Syntax
411
-
412
- The `match` property uses slash-separated segments to target items. The first segment identifies the
413
- top-level tab by label, and remaining segments navigate into the sidebar tree. Label matching is
414
- case-insensitive.
415
-
416
- ```json
417
- match: "Users/Get User"; // by label
418
- match: "Users/0"; // first item
419
- match: "Users/-1"; // last item
420
- match: "Users/Advanced/0"; // mixed nesting
421
- ```
1
+ ---
2
+ title: Navigation
3
+ sidebar_icon: compass
4
+ description:
5
+ Learn how to configure the navigation in APIToGo, including links, categories, documents, and
6
+ custom pages. Understand the structure of the navigation array and how to use icons, labels, and
7
+ paths.
8
+ ---
9
+
10
+ import { Book, Code, FileText } from "@lukoweb/apitogo/icons";
11
+
12
+ APIToGo uses a single `navigation` array to control both the top navigation tabs and the sidebar.
13
+ Items at the root of this array appear as tabs, and nested items build the sidebar tree. Navigation
14
+ entries can be links, document references, categories or custom pages.
15
+
16
+ ## Basic configuration
17
+
18
+ The navigation is defined using the `navigation` array in the APIToGo config file. Each item can be
19
+ one of several types. At the simplest level you may only have links and categories.
20
+
21
+ ```tsx title="config"
22
+ {
23
+ "navigation": [
24
+ {
25
+ "type": "category",
26
+ "label": "Documentation",
27
+ "icon": "book",
28
+ "items": [
29
+ {
30
+ "type": "doc",
31
+ "file": "documentation/introduction",
32
+ "label": "Introduction",
33
+ "icon": "file-text"
34
+ },
35
+ {
36
+ "type": "doc",
37
+ "file": "documentation/getting-started",
38
+ "path": "/docs/quick-start",
39
+ "label": "Quick Start"
40
+ }
41
+ ]
42
+ },
43
+ {
44
+ "type": "link",
45
+ "to": "/api",
46
+ "label": "API Reference",
47
+ "icon": "code",
48
+ "description": "Complete API documentation",
49
+ "badge": {
50
+ "label": "v2.0",
51
+ "color": "blue"
52
+ },
53
+ "display": "always"
54
+ }
55
+ ]
56
+ }
57
+ ```
58
+
59
+ ## Generate navigation automatically
60
+
61
+ In a config version 2 project, the portal builds the sidebar from the pages under
62
+ `apitogo/portal/pages/`: the index page first, then the other pages by name, then one section per
63
+ folder. There is no `navigation` key to maintain. Add a page with **`npx apitogo config`** (see
64
+ **[Make config (CLI)](./make-config.mdx)**) or by creating the `.md` / `.mdx` file.
65
+
66
+ ## Navigation Items
67
+
68
+ Navigation items can be of these types: `category`, `doc`, `link`, or `custom-page`.
69
+
70
+ - `link`: A direct link to a page or external URL.
71
+ - `category`: A group of links that can be expanded or collapsed.
72
+ - `doc`: A reference to a document by it's file path: `file`.
73
+ - `custom-pages`: A custom page that is made of a React component, see
74
+ [Custom Pages](../guides/custom-pages.md)
75
+
76
+ ### `type: link`
77
+
78
+ `link` is the most basic item, it directly links to a path or URL. Use this for external resources
79
+ or standalone pages.
80
+
81
+ ```json
82
+ {
83
+ "type": "link",
84
+ "label": "Support",
85
+ "to": "/my/api" // or: https://example.com/my-external-link
86
+ }
87
+ ```
88
+
89
+ <details>
90
+ <summary>**TypeScript type declaration**</summary>
91
+ ```ts
92
+ type NavigationLink = {
93
+ type: "link";
94
+ to: string;
95
+ label: string;
96
+ icon?: string; // Lucide icon name
97
+ description?: string;
98
+ badge?: {
99
+ label: string;
100
+ color: "green" | "blue" | "yellow" | "red" | "purple" | "indigo" | "gray" | "outline";
101
+ };
102
+ display?:
103
+ | "auth"
104
+ | "anon"
105
+ | "always"
106
+ | "hide"
107
+ | ((params: { context: ApitogoContext; auth: UseAuthReturn }) => boolean);
108
+ target?: "_self" | "_blank";
109
+ };
110
+ ```
111
+ </details>
112
+
113
+ ### `type: category`
114
+
115
+ The `category` type groups related items under a collapsible section. The `label` is the displayed
116
+ text, and the `items` array contains `id`s of documents, links, or other categories.
117
+
118
+ ```json
119
+ {
120
+ "type": "category",
121
+ "label": "Getting Started",
122
+ "collapsible": true, // optional
123
+ "collapsed": false, // optional
124
+ "items": [
125
+ {
126
+ "type": "link",
127
+ "label": "Support",
128
+ "to": "https://support.example.com"
129
+ }
130
+ ]
131
+ }
132
+ ```
133
+
134
+ <details>
135
+ <summary>**TypeScript type declaration**</summary>
136
+
137
+ ```ts
138
+ type NavigationCategory = {
139
+ type: "category";
140
+ icon?: string; // Lucide icon name
141
+ items: Array<NavigationDoc | NavigationLink | NavigationCategory | NavigationCustomPage>;
142
+ label: string;
143
+ collapsible?: boolean;
144
+ collapsed?: boolean;
145
+ link?: string | { type: "doc"; file: string; label?: string };
146
+ display?:
147
+ | "auth"
148
+ | "anon"
149
+ | "always"
150
+ | "hide"
151
+ | ((params: { context: ApitogoContext; auth: UseAuthReturn }) => boolean);
152
+ };
153
+ ```
154
+
155
+ </details>
156
+
157
+ ### `type: doc`
158
+
159
+ Doc is used to reference markdown files. The `label` is the text that will be displayed, and the
160
+ `file` is the file path associated with a markdown file.
161
+
162
+ ```json
163
+ {
164
+ "type": "doc",
165
+ "label": "Overview",
166
+ "file": "docs/overview"
167
+ }
168
+ ```
169
+
170
+ <details>
171
+ <summary>**TypeScript type declaration**</summary>
172
+
173
+ ```ts
174
+ type NavigationDoc = {
175
+ type: "doc";
176
+ file: string;
177
+ path?: string;
178
+ icon?: string;
179
+ label?: string;
180
+ badge?: {
181
+ label: string;
182
+ color: "green" | "blue" | "yellow" | "red" | "purple" | "indigo" | "gray" | "outline";
183
+ };
184
+ display?:
185
+ | "auth"
186
+ | "anon"
187
+ | "always"
188
+ | "hide"
189
+ | ((params: { context: ApitogoContext; auth: UseAuthReturn }) => boolean);
190
+ };
191
+ ```
192
+
193
+ </details>
194
+
195
+ #### Using shorthands
196
+
197
+ Documents can be referenced as strings (using their file path), which is equivalent to
198
+ `{ "type": "doc", "file": "path" }`:
199
+
200
+ ```json
201
+ {
202
+ "navigation": [
203
+ {
204
+ "type": "category",
205
+ "label": "Documentation",
206
+ "icon": "book",
207
+ "items": [
208
+ "documentation/introduction",
209
+ "documentation/getting-started",
210
+ "documentation/installation"
211
+ ]
212
+ },
213
+ {
214
+ "type": "link",
215
+ "to": "/api",
216
+ "label": "API Reference",
217
+ "icon": "code"
218
+ }
219
+ ]
220
+ }
221
+ ```
222
+
223
+ This is much more concise when you don't need custom labels, icons, or other properties for
224
+ individual documents.
225
+
226
+ Learn more in the [Markdown documentation](/docs/markdown/overview)
227
+
228
+ #### Custom paths
229
+
230
+ The `path` property allows you to customize the URL path for a document. By default, APIToGo uses
231
+ the file path to generate the URL, but you can override this behavior by specifying a custom path.
232
+
233
+ ### `type: custom-page`
234
+
235
+ Custom pages allow you to create standalone pages that are not tied to a Markdown document. This is
236
+ useful for creating landing pages, dashboards, or any other custom content.
237
+
238
+ ```tsx
239
+ {
240
+ type: "custom-page",
241
+ path: "/a-custom-page",
242
+ element: <MyCustomPage />,
243
+ display: "always"
244
+ }
245
+ ```
246
+
247
+ <details>
248
+ <summary>**TypeScript type declaration**</summary>
249
+
250
+ ```ts
251
+ type NavigationCustomPage = {
252
+ type: "custom-page";
253
+ path: string;
254
+ label?: string;
255
+ element: any;
256
+ icon?: string; // Lucide icon name
257
+ badge?: {
258
+ label: string;
259
+ color: "green" | "blue" | "yellow" | "red" | "purple" | "indigo" | "gray" | "outline";
260
+ invert?: boolean;
261
+ };
262
+ display?:
263
+ | "auth"
264
+ | "anon"
265
+ | "always"
266
+ | "hide"
267
+ | ((params: { context: ApitogoContext; auth: UseAuthReturn }) => boolean);
268
+ };
269
+ ```
270
+
271
+ </details>
272
+
273
+ ## Display Control
274
+
275
+ All navigation items support a `display` property that controls when the item should be visible:
276
+
277
+ - `"always"` (default): Always visible
278
+ - `"auth"`: Only visible when user is authenticated
279
+ - `"anon"`: Only visible when user is not authenticated
280
+ - `"hide"`: Never visible (useful for temporarily hiding items)
281
+ - **callback function**: For custom logic, pass a function that receives `{ context, auth }` and
282
+ returns a boolean
283
+
284
+ ```json
285
+ {
286
+ "type": "link",
287
+ "label": "Admin Panel",
288
+ "to": "/admin",
289
+ "display": "auth"
290
+ }
291
+ ```
292
+
293
+ ### Custom Display Logic
294
+
295
+ For more complex visibility rules, use a callback function:
296
+
297
+ ```tsx
298
+ {
299
+ type: "link",
300
+ label: "Premium Features",
301
+ to: "/premium",
302
+ display: ({ auth }) => {
303
+ // Show only for users with premium role
304
+ return auth.user?.role === "premium";
305
+ }
306
+ }
307
+ ```
308
+
309
+ The callback receives:
310
+
311
+ - `context`: The APIToGo runtime context (TypeScript type: `ApitogoContext`)
312
+ - `auth`: The authentication state from `UseAuthReturn`, including `user`, `isAuthenticated`, etc.
313
+
314
+ ## Badges
315
+
316
+ Navigation items can display badges with labels and colors. Badges support an optional `invert`
317
+ property for styling:
318
+
319
+ ```json
320
+ {
321
+ "type": "doc",
322
+ "file": "api/v2",
323
+ "badge": {
324
+ "label": "Beta",
325
+ "color": "yellow"
326
+ }
327
+ }
328
+ ```
329
+
330
+ ## Icons
331
+
332
+ Icons can be added to categories and documents by specifying an `icon` property. The value should be
333
+ the name of a [Lucide icon](https://lucide.dev/icons) (e.g., `book` <Book size={16}
334
+ style={{ display: 'inline' }} />, `code` <Code size={16} style={{ display: 'inline' }} />,
335
+ `file-text` <FileText size={16} style={{ display: 'inline' }} />).
336
+
337
+ ```json
338
+ {
339
+ "type": "category",
340
+ "label": "Getting Started",
341
+ "icon": "book"
342
+ }
343
+ ```
344
+
345
+ They can also be set on individual documents in their front matter:
346
+
347
+ ```md
348
+ ---
349
+ title: My Document
350
+ sidebar_icon: book
351
+ ---
352
+ ```
353
+
354
+ ## Title & Labels
355
+
356
+ All navigation items can have a `label` property that determines the displayed text. For `doc`
357
+ items, the `label` is optional; if omitted, APIToGo uses the document's `title` from its front
358
+ matter or the first `#` header.
359
+
360
+ To override the navigation label without changing the document's `title`, use the `sidebar_label`
361
+ property in the front matter:
362
+
363
+ ```md
364
+ ---
365
+ title: My Long Title
366
+ sidebar_label: Short Title
367
+ ---
368
+ ```
369
+
370
+ In this example, the document's title remains "My Long Title," but the sidebar displays "Short
371
+ Title."
372
+
373
+ ## Navigation Rules
374
+
375
+ Plugins generate sidebar navigation automatically (e.g. from OpenAPI tags). Navigation rules let you
376
+ customize that generated sidebar by inserting, modifying, sorting, moving, or removing items. To
377
+ change the top-level tabs themselves, use the `navigation` array directly.
378
+
379
+ ```tsx
380
+ navigationRules: [
381
+ {
382
+ type: "sort",
383
+ match: "Shipments",
384
+ by: (a, b) => a.label.localeCompare(b.label),
385
+ },
386
+ ],
387
+ ```
388
+
389
+ For a practical walkthrough with more examples, see the
390
+ [Navigation Rules](/docs/guides/navigation-rules) guide.
391
+
392
+ ### Rule Types
393
+
394
+ Each rule has a `type` and a `match` property that targets a navigation item.
395
+
396
+ | Type | Description |
397
+ | -------- | ------------------------------------------------------------------------- |
398
+ | `insert` | Add items `before` or `after` a matched item |
399
+ | `modify` | Change `label`, `icon`, `badge`, `collapsed`, `collapsible`, or `display` |
400
+ | `remove` | Remove a matched item from the sidebar |
401
+ | `sort` | Sort children of a matched category using a custom comparator |
402
+ | `move` | Relocate a matched item `before` or `after` another item |
403
+
404
+ ### Match Syntax
405
+
406
+ The `match` property uses slash-separated segments to target items. The first segment identifies the
407
+ top-level tab by label, and remaining segments navigate into the sidebar tree. Label matching is
408
+ case-insensitive.
409
+
410
+ ```json
411
+ match: "Users/Get User"; // by label
412
+ match: "Users/0"; // first item
413
+ match: "Users/-1"; // last item
414
+ match: "Users/Advanced/0"; // mixed nesting
415
+ ```