@alliance-droid/svelte-docs-system 0.0.1
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.
- package/COMPONENTS.md +365 -0
- package/COVERAGE_REPORT.md +663 -0
- package/README.md +42 -0
- package/SEARCH_VERIFICATION.md +229 -0
- package/TEST_SUMMARY.md +344 -0
- package/bin/init.js +821 -0
- package/docs/E2E_TESTS.md +354 -0
- package/docs/TESTING.md +754 -0
- package/docs/de/index.md +41 -0
- package/docs/en/COMPONENTS.md +443 -0
- package/docs/en/api/examples.md +100 -0
- package/docs/en/api/overview.md +69 -0
- package/docs/en/components/index.md +622 -0
- package/docs/en/config/navigation.md +505 -0
- package/docs/en/config/theme-and-colors.md +395 -0
- package/docs/en/getting-started/integration.md +406 -0
- package/docs/en/guides/common-setups.md +651 -0
- package/docs/en/index.md +243 -0
- package/docs/en/markdown.md +102 -0
- package/docs/en/routing.md +64 -0
- package/docs/en/setup.md +52 -0
- package/docs/en/troubleshooting.md +704 -0
- package/docs/es/index.md +41 -0
- package/docs/fr/index.md +41 -0
- package/docs/ja/index.md +41 -0
- package/package.json +40 -0
- package/pagefind.toml +8 -0
- package/postcss.config.js +5 -0
- package/src/app.css +119 -0
- package/src/app.d.ts +13 -0
- package/src/app.html +11 -0
- package/src/lib/assets/favicon.svg +1 -0
- package/src/lib/components/APITable.svelte +120 -0
- package/src/lib/components/APITable.test.ts +153 -0
- package/src/lib/components/Breadcrumbs.svelte +85 -0
- package/src/lib/components/Breadcrumbs.test.ts +148 -0
- package/src/lib/components/Callout.svelte +60 -0
- package/src/lib/components/Callout.test.ts +100 -0
- package/src/lib/components/CodeBlock.svelte +68 -0
- package/src/lib/components/CodeBlock.test.ts +133 -0
- package/src/lib/components/DocLayout.svelte +84 -0
- package/src/lib/components/Footer.svelte +78 -0
- package/src/lib/components/Image.svelte +100 -0
- package/src/lib/components/Image.test.ts +163 -0
- package/src/lib/components/Navbar.svelte +141 -0
- package/src/lib/components/Search.svelte +248 -0
- package/src/lib/components/Sidebar.svelte +110 -0
- package/src/lib/components/Tabs.svelte +48 -0
- package/src/lib/components/Tabs.test.ts +102 -0
- package/src/lib/config.test.ts +140 -0
- package/src/lib/config.ts +179 -0
- package/src/lib/configIntegration.test.ts +272 -0
- package/src/lib/configLoader.ts +231 -0
- package/src/lib/configParser.test.ts +217 -0
- package/src/lib/configParser.ts +234 -0
- package/src/lib/index.ts +34 -0
- package/src/lib/integration.test.ts +426 -0
- package/src/lib/navigationBuilder.test.ts +338 -0
- package/src/lib/navigationBuilder.ts +268 -0
- package/src/lib/performance.test.ts +369 -0
- package/src/lib/routing.test.ts +202 -0
- package/src/lib/routing.ts +127 -0
- package/src/lib/search-functionality.test.ts +493 -0
- package/src/lib/stores/i18n.test.ts +180 -0
- package/src/lib/stores/i18n.ts +143 -0
- package/src/lib/stores/nav.ts +36 -0
- package/src/lib/stores/search.test.ts +140 -0
- package/src/lib/stores/search.ts +162 -0
- package/src/lib/stores/theme.ts +59 -0
- package/src/lib/stores/version.test.ts +139 -0
- package/src/lib/stores/version.ts +111 -0
- package/src/lib/themeCustomization.test.ts +223 -0
- package/src/lib/themeCustomization.ts +212 -0
- package/src/lib/utils/highlight.test.ts +136 -0
- package/src/lib/utils/highlight.ts +100 -0
- package/src/lib/utils/index.ts +7 -0
- package/src/lib/utils/markdown.test.ts +357 -0
- package/src/lib/utils/markdown.ts +77 -0
- package/src/routes/+layout.server.ts +1 -0
- package/src/routes/+layout.svelte +28 -0
- package/src/routes/+page.svelte +165 -0
- package/static/robots.txt +3 -0
- package/svelte.config.js +18 -0
- package/tailwind.config.ts +55 -0
- package/template-starter/.github/workflows/build.yml +40 -0
- package/template-starter/.github/workflows/deploy-github-pages.yml +47 -0
- package/template-starter/.github/workflows/deploy-netlify.yml +41 -0
- package/template-starter/.github/workflows/deploy-vercel.yml +64 -0
- package/template-starter/NPM-PACKAGE-SETUP.md +233 -0
- package/template-starter/README.md +320 -0
- package/template-starter/docs/_config.json +39 -0
- package/template-starter/docs/api/components.md +257 -0
- package/template-starter/docs/api/overview.md +169 -0
- package/template-starter/docs/guides/configuration.md +145 -0
- package/template-starter/docs/guides/github-pages-deployment.md +254 -0
- package/template-starter/docs/guides/netlify-deployment.md +159 -0
- package/template-starter/docs/guides/vercel-deployment.md +131 -0
- package/template-starter/docs/index.md +49 -0
- package/template-starter/docs/setup.md +149 -0
- package/template-starter/package.json +31 -0
- package/template-starter/pagefind.toml +3 -0
- package/template-starter/postcss.config.js +5 -0
- package/template-starter/src/app.css +34 -0
- package/template-starter/src/app.d.ts +13 -0
- package/template-starter/src/app.html +11 -0
- package/template-starter/src/lib/components/APITable.svelte +120 -0
- package/template-starter/src/lib/components/APITable.test.ts +19 -0
- package/template-starter/src/lib/components/Breadcrumbs.svelte +85 -0
- package/template-starter/src/lib/components/Breadcrumbs.test.ts +19 -0
- package/template-starter/src/lib/components/Callout.svelte +60 -0
- package/template-starter/src/lib/components/Callout.test.ts +16 -0
- package/template-starter/src/lib/components/CodeBlock.svelte +68 -0
- package/template-starter/src/lib/components/CodeBlock.test.ts +12 -0
- package/template-starter/src/lib/components/DocLayout.svelte +84 -0
- package/template-starter/src/lib/components/Footer.svelte +78 -0
- package/template-starter/src/lib/components/Image.svelte +100 -0
- package/template-starter/src/lib/components/Image.test.ts +15 -0
- package/template-starter/src/lib/components/Navbar.svelte +141 -0
- package/template-starter/src/lib/components/Search.svelte +248 -0
- package/template-starter/src/lib/components/Sidebar.svelte +110 -0
- package/template-starter/src/lib/components/Tabs.svelte +48 -0
- package/template-starter/src/lib/components/Tabs.test.ts +17 -0
- package/template-starter/src/lib/index.ts +15 -0
- package/template-starter/src/routes/+layout.svelte +28 -0
- package/template-starter/src/routes/+page.svelte +92 -0
- package/template-starter/svelte.config.js +17 -0
- package/template-starter/tailwind.config.ts +17 -0
- package/template-starter/tsconfig.json +13 -0
- package/template-starter/vite.config.ts +6 -0
- package/tests/e2e/example.spec.ts +345 -0
- package/tsconfig.json +20 -0
- package/vite.config.ts +6 -0
- package/vitest.config.ts +34 -0
- package/vitest.setup.ts +21 -0
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Navigation Configuration
|
|
3
|
+
description: Configure sidebar, navbar, and breadcrumb navigation
|
|
4
|
+
author: Andrew
|
|
5
|
+
date: 2026-02-05
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Navigation Configuration
|
|
9
|
+
|
|
10
|
+
Learn how to configure the navigation structure, sidebar sections, and breadcrumbs.
|
|
11
|
+
|
|
12
|
+
## Navigation Store
|
|
13
|
+
|
|
14
|
+
The navigation system uses a Svelte store to manage the navigation structure globally. Access it in any component:
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { nav, sidebarOpen } from '$lib/stores/nav';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Sidebar Navigation
|
|
21
|
+
|
|
22
|
+
### Basic Configuration
|
|
23
|
+
|
|
24
|
+
Define your navigation structure in `src/routes/docs/+layout.svelte`:
|
|
25
|
+
|
|
26
|
+
```svelte
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
import type { NavSection, NavItem } from '$lib/stores/nav';
|
|
29
|
+
|
|
30
|
+
const sections: NavSection[] = [
|
|
31
|
+
{
|
|
32
|
+
title: 'Getting Started',
|
|
33
|
+
items: [
|
|
34
|
+
{ label: 'Home', href: '/docs' },
|
|
35
|
+
{ label: 'Installation', href: '/docs/installation' },
|
|
36
|
+
{ label: 'Quick Start', href: '/docs/quick-start' },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'Components',
|
|
41
|
+
items: [
|
|
42
|
+
{ label: 'Overview', href: '/docs/components' },
|
|
43
|
+
{ label: 'DocLayout', href: '/docs/components/doclayout' },
|
|
44
|
+
{ label: 'Navbar', href: '/docs/components/navbar' },
|
|
45
|
+
{ label: 'Sidebar', href: '/docs/components/sidebar' },
|
|
46
|
+
{ label: 'Footer', href: '/docs/components/footer' },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: 'Guides',
|
|
51
|
+
items: [
|
|
52
|
+
{ label: 'API Integration', href: '/docs/guides/api' },
|
|
53
|
+
{ label: 'Theming', href: '/docs/guides/theming' },
|
|
54
|
+
{ label: 'Deployment', href: '/docs/guides/deployment' },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<DocLayout {sections} title="Documentation" copyright="© 2026 My Project">
|
|
61
|
+
<slot />
|
|
62
|
+
</DocLayout>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Nested Navigation Items
|
|
66
|
+
|
|
67
|
+
Create multi-level navigation with nested items:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const sections: NavSection[] = [
|
|
71
|
+
{
|
|
72
|
+
title: 'Documentation',
|
|
73
|
+
items: [
|
|
74
|
+
{
|
|
75
|
+
label: 'Getting Started',
|
|
76
|
+
href: '/docs/getting-started',
|
|
77
|
+
children: [
|
|
78
|
+
{ label: 'Installation', href: '/docs/getting-started/installation' },
|
|
79
|
+
{ label: 'Configuration', href: '/docs/getting-started/config' },
|
|
80
|
+
{ label: 'First Steps', href: '/docs/getting-started/first-steps' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: 'API Reference',
|
|
85
|
+
href: '/docs/api',
|
|
86
|
+
children: [
|
|
87
|
+
{ label: 'Components', href: '/docs/api/components' },
|
|
88
|
+
{ label: 'Stores', href: '/docs/api/stores' },
|
|
89
|
+
{ label: 'Utilities', href: '/docs/api/utilities' },
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Navigation Item Properties
|
|
98
|
+
|
|
99
|
+
Each `NavItem` has these properties:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
interface NavItem {
|
|
103
|
+
label: string; // Display text in sidebar
|
|
104
|
+
href?: string; // URL path (optional for parent items)
|
|
105
|
+
icon?: string; // FontAwesome icon name (optional)
|
|
106
|
+
children?: NavItem[]; // Nested items (optional)
|
|
107
|
+
isActive?: boolean; // Manually set active state (optional)
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Example with icons:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const sections: NavSection[] = [
|
|
115
|
+
{
|
|
116
|
+
title: 'Navigation',
|
|
117
|
+
items: [
|
|
118
|
+
{ label: 'Home', href: '/docs', icon: 'home' },
|
|
119
|
+
{ label: 'Getting Started', href: '/docs/start', icon: 'rocket' },
|
|
120
|
+
{ label: 'API', href: '/docs/api', icon: 'code' },
|
|
121
|
+
{ label: 'Guides', href: '/docs/guides', icon: 'book' },
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Dynamic Navigation
|
|
128
|
+
|
|
129
|
+
Generate navigation from your documentation structure:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { readdirSync } from 'fs';
|
|
133
|
+
import { join } from 'path';
|
|
134
|
+
|
|
135
|
+
function generateNav(): NavSection[] {
|
|
136
|
+
const docsPath = join(process.cwd(), 'docs/en');
|
|
137
|
+
|
|
138
|
+
// Read directory structure
|
|
139
|
+
const files = readdirSync(docsPath);
|
|
140
|
+
|
|
141
|
+
const items: NavItem[] = files
|
|
142
|
+
.filter(f => f.endsWith('.md') && f !== 'index.md')
|
|
143
|
+
.map(f => {
|
|
144
|
+
const name = f.replace('.md', '');
|
|
145
|
+
return {
|
|
146
|
+
label: name
|
|
147
|
+
.split('-')
|
|
148
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
149
|
+
.join(' '),
|
|
150
|
+
href: `/docs/${name}`,
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return [
|
|
155
|
+
{
|
|
156
|
+
title: 'Documentation',
|
|
157
|
+
items: [
|
|
158
|
+
{ label: 'Home', href: '/docs' },
|
|
159
|
+
...items,
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Use in your layout
|
|
166
|
+
const sections = generateNav();
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Active State Highlighting
|
|
170
|
+
|
|
171
|
+
The sidebar automatically highlights the current page. To manually control active state:
|
|
172
|
+
|
|
173
|
+
```svelte
|
|
174
|
+
<script lang="ts">
|
|
175
|
+
import { page } from '$app/stores';
|
|
176
|
+
|
|
177
|
+
let currentPath = $derived($page.url.pathname);
|
|
178
|
+
|
|
179
|
+
const sections: NavSection[] = [
|
|
180
|
+
{
|
|
181
|
+
title: 'Docs',
|
|
182
|
+
items: [
|
|
183
|
+
{
|
|
184
|
+
label: 'Home',
|
|
185
|
+
href: '/docs',
|
|
186
|
+
isActive: currentPath === '/docs',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
label: 'Setup',
|
|
190
|
+
href: '/docs/setup',
|
|
191
|
+
isActive: currentPath === '/docs/setup',
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
];
|
|
196
|
+
</script>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Sidebar Configuration
|
|
200
|
+
|
|
201
|
+
The `Sidebar` component accepts these props:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
interface SidebarProps {
|
|
205
|
+
sections: NavSection[]; // Navigation sections
|
|
206
|
+
currentPath: string; // Current route for active highlighting
|
|
207
|
+
onNavigate?: (path: string) => void; // Called when item clicked
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Mobile Sidebar Behavior
|
|
212
|
+
|
|
213
|
+
On mobile, the sidebar:
|
|
214
|
+
- Appears as an overlay when toggled
|
|
215
|
+
- Auto-closes after navigation
|
|
216
|
+
- Shows a backdrop overlay
|
|
217
|
+
- Slides in from the left
|
|
218
|
+
|
|
219
|
+
Configure in `src/lib/components/Sidebar.svelte`:
|
|
220
|
+
|
|
221
|
+
```svelte
|
|
222
|
+
<script lang="ts">
|
|
223
|
+
import { sidebarOpen } from '$lib/stores/nav';
|
|
224
|
+
|
|
225
|
+
function closeSidebar() {
|
|
226
|
+
sidebarOpen.set(false);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function handleNavigate(path: string) {
|
|
230
|
+
// Navigate and close on mobile
|
|
231
|
+
window.location.href = path;
|
|
232
|
+
if (window.innerWidth < 768) {
|
|
233
|
+
sidebarOpen.set(false);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
</script>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Navbar Configuration
|
|
240
|
+
|
|
241
|
+
Configure navbar items in `src/routes/docs/+layout.svelte`:
|
|
242
|
+
|
|
243
|
+
```svelte
|
|
244
|
+
<script lang="ts">
|
|
245
|
+
import Navbar from '$lib/components/Navbar.svelte';
|
|
246
|
+
|
|
247
|
+
let navbarConfig = {
|
|
248
|
+
title: 'My Docs',
|
|
249
|
+
logo: '/logo.svg',
|
|
250
|
+
onLogoClick: () => window.location.href = '/',
|
|
251
|
+
};
|
|
252
|
+
</script>
|
|
253
|
+
|
|
254
|
+
<Navbar {...navbarConfig} />
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Language Selector
|
|
258
|
+
|
|
259
|
+
Add language switching to navbar (if using i18n):
|
|
260
|
+
|
|
261
|
+
```svelte
|
|
262
|
+
<script lang="ts">
|
|
263
|
+
import { page } from '$app/stores';
|
|
264
|
+
|
|
265
|
+
let languages = [
|
|
266
|
+
{ code: 'en', label: 'English' },
|
|
267
|
+
{ code: 'es', label: 'Español' },
|
|
268
|
+
{ code: 'fr', label: 'Français' },
|
|
269
|
+
];
|
|
270
|
+
|
|
271
|
+
function switchLanguage(lang: string) {
|
|
272
|
+
const currentPath = $page.url.pathname.replace('/docs', '');
|
|
273
|
+
window.location.href = `/docs/${lang}${currentPath}`;
|
|
274
|
+
}
|
|
275
|
+
</script>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Version Selector
|
|
279
|
+
|
|
280
|
+
Add version switching (for multi-version docs):
|
|
281
|
+
|
|
282
|
+
```svelte
|
|
283
|
+
<script lang="ts">
|
|
284
|
+
let versions = [
|
|
285
|
+
{ number: '2.0', label: 'Latest' },
|
|
286
|
+
{ number: '1.5', label: '1.5 (LTS)' },
|
|
287
|
+
{ number: '1.0', label: '1.0 (Archived)' },
|
|
288
|
+
];
|
|
289
|
+
|
|
290
|
+
function switchVersion(version: string) {
|
|
291
|
+
window.location.href = `/docs/${version}/`;
|
|
292
|
+
}
|
|
293
|
+
</script>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Breadcrumbs
|
|
297
|
+
|
|
298
|
+
The `Breadcrumbs` component displays the current page path:
|
|
299
|
+
|
|
300
|
+
```svelte
|
|
301
|
+
<script lang="ts">
|
|
302
|
+
import Breadcrumbs from '$lib/components/Breadcrumbs.svelte';
|
|
303
|
+
|
|
304
|
+
let items = [
|
|
305
|
+
{ label: 'Home', href: '/' },
|
|
306
|
+
{ label: 'Docs', href: '/docs' },
|
|
307
|
+
{ label: 'Getting Started', href: '/docs/getting-started' },
|
|
308
|
+
{ label: 'Installation' }, // Current page (no href)
|
|
309
|
+
];
|
|
310
|
+
</script>
|
|
311
|
+
|
|
312
|
+
<Breadcrumbs {items} />
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Auto-Generate Breadcrumbs from Current Path
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
function generateBreadcrumbs(pathname: string) {
|
|
319
|
+
const segments = pathname
|
|
320
|
+
.split('/')
|
|
321
|
+
.filter(s => s && s !== 'docs');
|
|
322
|
+
|
|
323
|
+
const items = [
|
|
324
|
+
{ label: 'Docs', href: '/docs' },
|
|
325
|
+
...segments.map((segment, index) => {
|
|
326
|
+
const href = '/docs/' + segments.slice(0, index + 1).join('/');
|
|
327
|
+
const label = segment
|
|
328
|
+
.split('-')
|
|
329
|
+
.map(w => w.charAt(0).toUpperCase() + w.slice(1))
|
|
330
|
+
.join(' ');
|
|
331
|
+
|
|
332
|
+
return {
|
|
333
|
+
label,
|
|
334
|
+
href: index === segments.length - 1 ? undefined : href,
|
|
335
|
+
};
|
|
336
|
+
}),
|
|
337
|
+
];
|
|
338
|
+
|
|
339
|
+
return items;
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Section Collapsing
|
|
344
|
+
|
|
345
|
+
Make sidebar sections collapsible:
|
|
346
|
+
|
|
347
|
+
```svelte
|
|
348
|
+
<script lang="ts">
|
|
349
|
+
let expandedSections: Set<string> = new Set();
|
|
350
|
+
|
|
351
|
+
function toggleSection(title: string) {
|
|
352
|
+
if (expandedSections.has(title)) {
|
|
353
|
+
expandedSections.delete(title);
|
|
354
|
+
} else {
|
|
355
|
+
expandedSections.add(title);
|
|
356
|
+
}
|
|
357
|
+
expandedSections = expandedSections;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const sections: NavSection[] = [
|
|
361
|
+
{ title: 'Getting Started', items: [...] },
|
|
362
|
+
{ title: 'Components', items: [...] },
|
|
363
|
+
];
|
|
364
|
+
</script>
|
|
365
|
+
|
|
366
|
+
{#each sections as section (section.title)}
|
|
367
|
+
<div class="section">
|
|
368
|
+
<button on:click={() => toggleSection(section.title)}>
|
|
369
|
+
{section.title}
|
|
370
|
+
<span class:rotated={expandedSections.has(section.title)}>
|
|
371
|
+
▼
|
|
372
|
+
</span>
|
|
373
|
+
</button>
|
|
374
|
+
|
|
375
|
+
{#if expandedSections.has(section.title)}
|
|
376
|
+
<nav>
|
|
377
|
+
{#each section.items as item (item.label)}
|
|
378
|
+
<a href={item.href} class:active={item.isActive}>
|
|
379
|
+
{item.label}
|
|
380
|
+
</a>
|
|
381
|
+
{/each}
|
|
382
|
+
</nav>
|
|
383
|
+
{/if}
|
|
384
|
+
</div>
|
|
385
|
+
{/each}
|
|
386
|
+
|
|
387
|
+
<style>
|
|
388
|
+
.rotated {
|
|
389
|
+
transform: rotate(180deg);
|
|
390
|
+
}
|
|
391
|
+
</style>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
## Search Navigation
|
|
395
|
+
|
|
396
|
+
Integrate Pagefind search with navigation:
|
|
397
|
+
|
|
398
|
+
```svelte
|
|
399
|
+
<script lang="ts">
|
|
400
|
+
import Search from '$lib/components/Search.svelte';
|
|
401
|
+
import { sidebarOpen } from '$lib/stores/nav';
|
|
402
|
+
|
|
403
|
+
function handleSearch(result: SearchResult) {
|
|
404
|
+
window.location.href = result.url;
|
|
405
|
+
sidebarOpen.set(false);
|
|
406
|
+
}
|
|
407
|
+
</script>
|
|
408
|
+
|
|
409
|
+
<div class="navbar">
|
|
410
|
+
<Search onSelect={handleSearch} />
|
|
411
|
+
</div>
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
## Configuration Types
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
// Navigation types
|
|
418
|
+
interface NavSection {
|
|
419
|
+
title: string;
|
|
420
|
+
items: NavItem[];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
interface NavItem {
|
|
424
|
+
label: string;
|
|
425
|
+
href?: string;
|
|
426
|
+
icon?: string;
|
|
427
|
+
children?: NavItem[];
|
|
428
|
+
isActive?: boolean;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Store types
|
|
432
|
+
interface NavStoreData {
|
|
433
|
+
sections: NavSection[];
|
|
434
|
+
title?: string;
|
|
435
|
+
logo?: string | null;
|
|
436
|
+
copyright?: string;
|
|
437
|
+
footerLinks?: { label: string; href: string }[];
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## Best Practices
|
|
442
|
+
|
|
443
|
+
1. **Group related items:** Use sections to organize navigation logically
|
|
444
|
+
2. **Limit depth:** Keep nesting to 2-3 levels maximum
|
|
445
|
+
3. **Use consistent labels:** Make labels clear and concise
|
|
446
|
+
4. **Add icons:** Use FontAwesome icons for visual clarity
|
|
447
|
+
5. **Test on mobile:** Ensure sidebar is usable on small screens
|
|
448
|
+
6. **Link to first child:** Parent items with `href` pointing to overview
|
|
449
|
+
7. **Update dynamically:** Load navigation from a config file or database
|
|
450
|
+
|
|
451
|
+
## Example: Complex Navigation
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
const sections: NavSection[] = [
|
|
455
|
+
{
|
|
456
|
+
title: 'Get Started',
|
|
457
|
+
items: [
|
|
458
|
+
{ label: 'Welcome', href: '/docs', icon: 'home' },
|
|
459
|
+
{ label: 'Installation', href: '/docs/install', icon: 'download' },
|
|
460
|
+
{ label: 'Quick Start', href: '/docs/quick-start', icon: 'rocket' },
|
|
461
|
+
],
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
title: 'Learn',
|
|
465
|
+
items: [
|
|
466
|
+
{
|
|
467
|
+
label: 'Core Concepts',
|
|
468
|
+
href: '/docs/concepts',
|
|
469
|
+
icon: 'lightbulb',
|
|
470
|
+
children: [
|
|
471
|
+
{ label: 'Architecture', href: '/docs/concepts/architecture' },
|
|
472
|
+
{ label: 'Components', href: '/docs/concepts/components' },
|
|
473
|
+
{ label: 'Stores', href: '/docs/concepts/stores' },
|
|
474
|
+
],
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
label: 'Guides',
|
|
478
|
+
href: '/docs/guides',
|
|
479
|
+
icon: 'book',
|
|
480
|
+
children: [
|
|
481
|
+
{ label: 'API Integration', href: '/docs/guides/api' },
|
|
482
|
+
{ label: 'Authentication', href: '/docs/guides/auth' },
|
|
483
|
+
{ label: 'Deployment', href: '/docs/guides/deploy' },
|
|
484
|
+
],
|
|
485
|
+
},
|
|
486
|
+
],
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
title: 'Reference',
|
|
490
|
+
items: [
|
|
491
|
+
{ label: 'API Docs', href: '/docs/api', icon: 'code' },
|
|
492
|
+
{ label: 'Components', href: '/docs/components', icon: 'puzzle' },
|
|
493
|
+
{ label: 'CLI', href: '/docs/cli', icon: 'terminal' },
|
|
494
|
+
],
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
title: 'Support',
|
|
498
|
+
items: [
|
|
499
|
+
{ label: 'FAQ', href: '/docs/faq', icon: 'circle-question' },
|
|
500
|
+
{ label: 'Troubleshooting', href: '/docs/troubleshooting', icon: 'wrench' },
|
|
501
|
+
{ label: 'Contributing', href: '/docs/contributing', icon: 'git' },
|
|
502
|
+
],
|
|
503
|
+
},
|
|
504
|
+
];
|
|
505
|
+
```
|