Loading...
Loading...
> The intelligent, collapsible sidebar used for navigating the Fabrk documentation. Features auto-numbering, search, and collapsible sections.
1import { DocsSidebar, type NavSection, type NavItem } from '@/components/docs/docs-sidebar';
Main content area for docs
1// In your layout.tsx or page.tsx2import { DocsSidebar } from '@/components/docs/docs-sidebar';3import { docsNavigation } from './docs-nav-data'; // Your navigation data45// Optional: Auto-numbering formatters6const formatSectionTitle = (title, index) =>7 `[${String(index + 1).padStart(2, '0')}] ${title}`;8const formatItemTitle = (title, itemIndex, sectionIndex, subSectionIndex) => {9 if (subSectionIndex !== undefined) return title;10 const secNum = String(sectionIndex + 1).padStart(2, '0');11 const itemNum = itemIndex + 1;12 return `[${secNum}.${itemNum}] ${title}`;13};1415function MyDocsLayout({ children }) {16 return (17 <div className="flex">18 <DocsSidebar19 navigation={docsNavigation}20 formatSectionTitle={formatSectionTitle}21 formatItemTitle={formatItemTitle}22 />23 <main>{children}</main>24 </div>25 );26}
| Prop | Type | Default | Description |
|---|---|---|---|
| navigation* | NavSection[] | - | An array defining the structure and content of the sidebar. Each NavSection represents a collapsible group, and can contain NavItems or nested SubSections. |
| formatSectionTitle | (title: string, index: number) => string | - | Optional. A function to customize the display format of section titles. Receives the raw title and its 0-based index. |
| formatItemTitle | (title: string, itemIndex: number, sectionIndex: number, subSectionIndex?: number) => string | - | Optional. A function to customize the display format of item titles. Receives the raw title, its 0-based index within its parent (section or sub-section), its parent section index, and an optional sub-section index. |
| className | string | - | Additional CSS classes for the sidebar container. |
Structure for top-level navigation sections.
1export interface NavSection {2 title: string; // Display title3 id?: string; // Optional unique ID4 href?: string; // Optional link for the section header5 icon?: LucideIcon; // Optional icon for the section header6 items: NavItem[]; // Array of direct items within this section7 subSections?: NavSubSection[]; // Optional array of nested sub-sections8}
Structure for individual navigation links.
1export interface NavItem {2 title: string; // Display title3 href: string; // Target URL4 icon: LucideIcon; // Lucide icon component5 external?: boolean; // True if it's an external link6}
Structure for nested collapsible groups within a section.
1export interface NavSubSection {2 title: string; // Display title for the sub-section header3 items: NavItem[]; // Array of items within this sub-section4}