polen 0.10.0-next.5 → 0.10.0-next.7
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/build/api/content/$$.d.ts +1 -0
- package/build/api/content/$$.d.ts.map +1 -1
- package/build/api/content/$$.js +1 -0
- package/build/api/content/$$.js.map +1 -1
- package/build/api/content/navbar.d.ts +10 -0
- package/build/api/content/navbar.d.ts.map +1 -0
- package/build/api/content/navbar.js +45 -0
- package/build/api/content/navbar.js.map +1 -0
- package/build/api/content/sidebar.d.ts +85 -5
- package/build/api/content/sidebar.d.ts.map +1 -1
- package/build/api/content/sidebar.js +151 -75
- package/build/api/content/sidebar.js.map +1 -1
- package/build/api/vite/plugins/pages.d.ts +1 -4
- package/build/api/vite/plugins/pages.d.ts.map +1 -1
- package/build/api/vite/plugins/pages.js +4 -42
- package/build/api/vite/plugins/pages.js.map +1 -1
- package/build/lib/file-router/scan.d.ts.map +1 -1
- package/build/lib/file-router/scan.js +6 -1
- package/build/lib/file-router/scan.js.map +1 -1
- package/build/sandbox.js +17 -2
- package/build/sandbox.js.map +1 -1
- package/build/template/components/HamburgerMenu.d.ts +9 -0
- package/build/template/components/HamburgerMenu.d.ts.map +1 -0
- package/build/template/components/HamburgerMenu.jsx +53 -0
- package/build/template/components/HamburgerMenu.jsx.map +1 -0
- package/build/template/components/NotFound.d.ts +2 -0
- package/build/template/components/NotFound.d.ts.map +1 -0
- package/build/template/components/NotFound.jsx +26 -0
- package/build/template/components/NotFound.jsx.map +1 -0
- package/build/template/components/ThemeToggle.d.ts +3 -0
- package/build/template/components/ThemeToggle.d.ts.map +1 -0
- package/build/template/components/ThemeToggle.jsx +10 -0
- package/build/template/components/ThemeToggle.jsx.map +1 -0
- package/build/template/contexts/ThemeContext.d.ts +12 -0
- package/build/template/contexts/ThemeContext.d.ts.map +1 -0
- package/build/template/contexts/ThemeContext.jsx +41 -0
- package/build/template/contexts/ThemeContext.jsx.map +1 -0
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.jsx +55 -39
- package/build/template/routes/root.jsx.map +1 -1
- package/package.json +1 -1
- package/src/api/content/$$.ts +1 -0
- package/src/api/content/navbar.test.ts +55 -0
- package/src/api/content/navbar.ts +61 -0
- package/src/api/content/sidebar.test.ts +297 -0
- package/src/api/content/sidebar.ts +235 -88
- package/src/api/vite/plugins/pages.ts +5 -51
- package/src/lib/file-router/scan.ts +7 -1
- package/src/sandbox.ts +20 -1
- package/src/template/components/HamburgerMenu.tsx +96 -0
- package/src/template/components/NotFound.tsx +28 -0
- package/src/template/components/ThemeToggle.tsx +21 -0
- package/src/template/contexts/ThemeContext.tsx +60 -0
- package/src/template/routes/root.tsx +74 -51
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/api/content/$$.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
1
|
+
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/api/content/$$.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
package/build/api/content/$$.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"$$.js","sourceRoot":"","sources":["../../../src/api/content/$$.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
1
|
+
{"version":3,"file":"$$.js","sourceRoot":"","sources":["../../../src/api/content/$$.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Page } from './page.ts';
|
2
|
+
export interface NavbarItem {
|
3
|
+
pathExp: string;
|
4
|
+
title: string;
|
5
|
+
}
|
6
|
+
/**
|
7
|
+
* Generate navbar items from a list of pages
|
8
|
+
*/
|
9
|
+
export declare const createNavbar: (pages: Page[]) => NavbarItem[];
|
10
|
+
//# sourceMappingURL=navbar.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../../../src/api/content/navbar.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,IAAI,EAAE,KAAG,UAAU,EAiDtD,CAAA"}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { Str } from '@wollybeard/kit';
|
2
|
+
/**
|
3
|
+
* Generate navbar items from a list of pages
|
4
|
+
*/
|
5
|
+
export const createNavbar = (pages) => {
|
6
|
+
const navbarItems = [];
|
7
|
+
// Group pages by their top-level directory/segment
|
8
|
+
const topLevelGroups = new Map();
|
9
|
+
pages.forEach(page => {
|
10
|
+
// Skip hidden pages
|
11
|
+
if (page.metadata.hidden)
|
12
|
+
return;
|
13
|
+
const firstSegment = page.route.logical.path[0];
|
14
|
+
if (firstSegment) {
|
15
|
+
if (!topLevelGroups.has(firstSegment)) {
|
16
|
+
topLevelGroups.set(firstSegment, []);
|
17
|
+
}
|
18
|
+
topLevelGroups.get(firstSegment).push(page);
|
19
|
+
}
|
20
|
+
});
|
21
|
+
// Add each top-level group to navbar
|
22
|
+
topLevelGroups.forEach((pages, segment) => {
|
23
|
+
// For directories, check if there's an index page
|
24
|
+
const indexPage = pages.find(p => p.route.logical.path.length === 1
|
25
|
+
&& p.route.file.path.relative.name === 'index');
|
26
|
+
// For single non-index files at top level
|
27
|
+
const singlePage = pages.length === 1 && pages[0].route.logical.path.length === 1
|
28
|
+
&& pages[0].route.file.path.relative.name !== 'index';
|
29
|
+
// Include in navbar if:
|
30
|
+
// 1. It's a directory with an index page, OR
|
31
|
+
// 2. It's a single top-level page (not index)
|
32
|
+
if (indexPage || singlePage) {
|
33
|
+
const title = Str.titlizeSlug(segment);
|
34
|
+
const pathExp = `/${segment}`;
|
35
|
+
navbarItems.push({
|
36
|
+
pathExp,
|
37
|
+
title,
|
38
|
+
});
|
39
|
+
}
|
40
|
+
});
|
41
|
+
// Sort navbar items alphabetically for consistency
|
42
|
+
navbarItems.sort((a, b) => a.title.localeCompare(b.title));
|
43
|
+
return navbarItems;
|
44
|
+
};
|
45
|
+
//# sourceMappingURL=navbar.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"navbar.js","sourceRoot":"","sources":["../../../src/api/content/navbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAQrC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAgB,EAAE;IAC1D,MAAM,WAAW,GAAiB,EAAE,CAAA;IAEpC,mDAAmD;IACnD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAA;IAEhD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,oBAAoB;QACpB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,OAAM;QAEhC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC/C,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;gBACtC,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CA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;AACpB,CAAC,CAAA"}
|
@@ -1,24 +1,104 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import type { ScanResult } from './scan.ts';
|
2
|
+
/**
|
3
|
+
* Represents a complete sidebar structure with navigation items.
|
4
|
+
* This is the main data structure used to render sidebars in the UI.
|
5
|
+
*/
|
4
6
|
export interface Sidebar {
|
7
|
+
/** Array of navigation items that can be either direct links or sections containing multiple links */
|
5
8
|
items: Item[];
|
6
9
|
}
|
10
|
+
/**
|
11
|
+
* A sidebar navigation item that can be either a direct link or a section containing multiple links.
|
12
|
+
* @see {@link ItemLink} for direct navigation links
|
13
|
+
* @see {@link ItemSection} for grouped navigation sections
|
14
|
+
*/
|
7
15
|
export type Item = ItemLink | ItemSection;
|
16
|
+
/**
|
17
|
+
* A direct navigation link in the sidebar.
|
18
|
+
* Used for pages that don't have child pages.
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* ```ts
|
22
|
+
* const link: ItemLink = {
|
23
|
+
* type: 'ItemLink',
|
24
|
+
* title: 'Getting Started',
|
25
|
+
* pathExp: 'guide/getting-started'
|
26
|
+
* }
|
27
|
+
* ```
|
28
|
+
*/
|
8
29
|
export interface ItemLink {
|
30
|
+
/** Discriminator for TypeScript union types */
|
9
31
|
type: `ItemLink`;
|
32
|
+
/** Display title for the link (e.g., "Getting Started") */
|
10
33
|
title: string;
|
34
|
+
/** Path expression relative to the base path, without leading slash (e.g., "guide/getting-started") */
|
11
35
|
pathExp: string;
|
12
36
|
}
|
37
|
+
/**
|
38
|
+
* A collapsible section in the sidebar that groups related links.
|
39
|
+
* Used for directories that contain multiple pages.
|
40
|
+
*
|
41
|
+
* @example
|
42
|
+
* ```ts
|
43
|
+
* const section: ItemSection = {
|
44
|
+
* type: 'ItemSection',
|
45
|
+
* title: 'Guide',
|
46
|
+
* pathExp: 'guide',
|
47
|
+
* isLinkToo: true, // Has an index page
|
48
|
+
* links: [
|
49
|
+
* { type: 'ItemLink', title: 'Installation', pathExp: 'guide/installation' },
|
50
|
+
* { type: 'ItemLink', title: 'Configuration', pathExp: 'guide/configuration' }
|
51
|
+
* ]
|
52
|
+
* }
|
53
|
+
* ```
|
54
|
+
*/
|
13
55
|
export interface ItemSection {
|
56
|
+
/** Discriminator for TypeScript union types */
|
14
57
|
type: `ItemSection`;
|
58
|
+
/** Display title for the section (e.g., "Guide", "API Reference") */
|
15
59
|
title: string;
|
60
|
+
/** Path expression for the section's index page, if it exists (e.g., "guide") */
|
16
61
|
pathExp: string;
|
62
|
+
/** Whether this section also acts as a link (true if the directory has an index page) */
|
17
63
|
isLinkToo: boolean;
|
64
|
+
/** Child navigation links within this section */
|
18
65
|
links: ItemLink[];
|
19
66
|
}
|
20
67
|
/**
|
21
|
-
*
|
68
|
+
* A mapping of route paths to their corresponding sidebar structures.
|
69
|
+
* Used to store different sidebars for different sections of a site.
|
70
|
+
*
|
71
|
+
* @example
|
72
|
+
* ```ts
|
73
|
+
* const sidebarIndex: SidebarIndex = {
|
74
|
+
* '/guide': { items: [...] }, // Sidebar for /guide section
|
75
|
+
* '/api': { items: [...] }, // Sidebar for /api section
|
76
|
+
* '/reference': { items: [...] } // Sidebar for /reference section
|
77
|
+
* }
|
78
|
+
* ```
|
79
|
+
*/
|
80
|
+
export type SidebarIndex = Record<string, Sidebar>;
|
81
|
+
/**
|
82
|
+
* Builds sidebars for all top-level directories that contain both an index page and nested content.
|
83
|
+
*
|
84
|
+
* This function analyzes a scan result to identify which directories should have sidebars.
|
85
|
+
* A directory gets a sidebar if it meets these criteria:
|
86
|
+
* 1. It's a top-level directory (e.g., /guide, /api, /docs)
|
87
|
+
* 2. It has an index page (e.g., /guide/index.md)
|
88
|
+
* 3. It has nested pages (e.g., /guide/getting-started.md, /guide/configuration.md)
|
89
|
+
*
|
90
|
+
* @param scanResult - The result of scanning pages, containing both a flat list and tree structure
|
91
|
+
* @returns A mapping of route paths to sidebar structures
|
92
|
+
*
|
93
|
+
* @example
|
94
|
+
* ```ts
|
95
|
+
* const scanResult = await Content.scan({ dir: './pages' })
|
96
|
+
* const sidebars = buildSidebarIndex(scanResult)
|
97
|
+
* // Returns: {
|
98
|
+
* // '/guide': { items: [...] },
|
99
|
+
* // '/api': { items: [...] }
|
100
|
+
* // }
|
101
|
+
* ```
|
22
102
|
*/
|
23
|
-
export declare const
|
103
|
+
export declare const buildSidebarIndex: (scanResult: ScanResult) => SidebarIndex;
|
24
104
|
//# sourceMappingURL=sidebar.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../src/api/content/sidebar.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../src/api/content/sidebar.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,sGAAsG;IACtG,KAAK,EAAE,IAAI,EAAE,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEzC;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,QAAQ;IACvB,+CAA+C;IAC/C,IAAI,EAAE,UAAU,CAAA;IAChB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAA;IACb,uGAAuG;IACvG,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,IAAI,EAAE,aAAa,CAAA;IACnB,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAA;IACb,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAA;IACf,yFAAyF;IACzF,SAAS,EAAE,OAAO,CAAA;IAClB,iDAAiD;IACjD,KAAK,EAAE,QAAQ,EAAE,CAAA;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,UAAU,KAAG,YAqC1D,CAAA"}
|
@@ -1,90 +1,166 @@
|
|
1
1
|
import { FileRouter } from '#lib/file-router/index';
|
2
|
-
import { Tree } from '@wollybeard/kit';
|
3
2
|
import { Str } from '@wollybeard/kit';
|
4
3
|
/**
|
5
|
-
*
|
4
|
+
* Builds sidebars for all top-level directories that contain both an index page and nested content.
|
5
|
+
*
|
6
|
+
* This function analyzes a scan result to identify which directories should have sidebars.
|
7
|
+
* A directory gets a sidebar if it meets these criteria:
|
8
|
+
* 1. It's a top-level directory (e.g., /guide, /api, /docs)
|
9
|
+
* 2. It has an index page (e.g., /guide/index.md)
|
10
|
+
* 3. It has nested pages (e.g., /guide/getting-started.md, /guide/configuration.md)
|
11
|
+
*
|
12
|
+
* @param scanResult - The result of scanning pages, containing both a flat list and tree structure
|
13
|
+
* @returns A mapping of route paths to sidebar structures
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* ```ts
|
17
|
+
* const scanResult = await Content.scan({ dir: './pages' })
|
18
|
+
* const sidebars = buildSidebarIndex(scanResult)
|
19
|
+
* // Returns: {
|
20
|
+
* // '/guide': { items: [...] },
|
21
|
+
* // '/api': { items: [...] }
|
22
|
+
* // }
|
23
|
+
* ```
|
6
24
|
*/
|
7
|
-
export const
|
8
|
-
const
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
25
|
+
export const buildSidebarIndex = (scanResult) => {
|
26
|
+
const sidebarIndex = {};
|
27
|
+
// Group pages by their top-level directory
|
28
|
+
const pagesByTopLevelDir = new Map();
|
29
|
+
for (const page of scanResult.list) {
|
30
|
+
const topLevelDir = page.route.logical.path[0];
|
31
|
+
// Skip pages that are not in a directory or are hidden
|
32
|
+
if (!topLevelDir || page.metadata.hidden)
|
33
|
+
continue;
|
34
|
+
if (!pagesByTopLevelDir.has(topLevelDir)) {
|
35
|
+
pagesByTopLevelDir.set(topLevelDir, []);
|
14
36
|
}
|
37
|
+
pagesByTopLevelDir.get(topLevelDir).push(page);
|
15
38
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
const sectionPath = [...basePath, ...currentPath];
|
28
|
-
const sectionPathExp = FileRouter.pathToExpression(sectionPath);
|
29
|
-
const sectionTitle = Str.titlizeSlug(routeName);
|
30
|
-
// Check if any child is an index page
|
31
|
-
const hasIndexChild = node.children.some(child => isIndexPage(child.value));
|
32
|
-
const section = {
|
33
|
-
type: `ItemSection`,
|
34
|
-
title: sectionTitle,
|
35
|
-
pathExp: sectionPathExp.startsWith('/') ? sectionPathExp.slice(1) : sectionPathExp,
|
36
|
-
isLinkToo: hasIndexChild, // Section is linkable if it has an index page
|
37
|
-
links: [],
|
38
|
-
};
|
39
|
-
// Process all children as links for this section
|
40
|
-
for (const child of node.children) {
|
41
|
-
const childPage = child.value;
|
42
|
-
if (child.children.length > 0) {
|
43
|
-
// This child has children - only collect its descendants, not the child itself
|
44
|
-
collectPagesFromNode(child, basePath, section.links);
|
45
|
-
}
|
46
|
-
else if (!childPage.metadata.hidden && !isIndexPage(childPage)) {
|
47
|
-
// This is a leaf node - add it as a link
|
48
|
-
section.links.push(pageToItemLink(childPage, basePath));
|
49
|
-
}
|
39
|
+
// Build sidebar for each directory that has an index page
|
40
|
+
for (const [topLevelDir, pages] of pagesByTopLevelDir) {
|
41
|
+
const hasIndexPage = pages.some(page => page.route.logical.path.length === 1
|
42
|
+
&& FileRouter.routeIsFromIndexFile(page.route));
|
43
|
+
// Skip directories without index pages
|
44
|
+
if (!hasIndexPage)
|
45
|
+
continue;
|
46
|
+
const pathExp = `/${topLevelDir}`;
|
47
|
+
const sidebar = buildSidebarForDirectory(topLevelDir, pages);
|
48
|
+
if (sidebar.items.length > 0) {
|
49
|
+
sidebarIndex[pathExp] = sidebar;
|
50
50
|
}
|
51
|
-
sections.push(section);
|
52
51
|
}
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
return sidebarIndex;
|
53
|
+
};
|
54
|
+
/**
|
55
|
+
* Builds a sidebar for a specific directory from its pages
|
56
|
+
*/
|
57
|
+
const buildSidebarForDirectory = (topLevelDir, pages) => {
|
58
|
+
const items = [];
|
59
|
+
// Group pages by their immediate parent path
|
60
|
+
const pagesByParent = new Map();
|
61
|
+
for (const page of pages) {
|
62
|
+
// Skip the index page at the top level directory
|
63
|
+
if (page.route.logical.path.length === 1 && FileRouter.routeIsFromIndexFile(page.route)) {
|
64
|
+
continue;
|
65
|
+
}
|
66
|
+
// Get the immediate parent path (e.g., for ['guide', 'advanced', 'tips'], parent is ['guide', 'advanced'])
|
67
|
+
const parentPath = page.route.logical.path.slice(0, -1).join('/');
|
68
|
+
if (!pagesByParent.has(parentPath)) {
|
69
|
+
pagesByParent.set(parentPath, []);
|
57
70
|
}
|
71
|
+
pagesByParent.get(parentPath).push(page);
|
58
72
|
}
|
59
|
-
|
60
|
-
const
|
61
|
-
//
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
73
|
+
// Process top-level pages (direct children of the directory)
|
74
|
+
const topLevelPages = pagesByParent.get(topLevelDir) || [];
|
75
|
+
// Sort pages by their directory order (extracted from file path)
|
76
|
+
const sortedTopLevelPages = [...topLevelPages].sort((a, b) => {
|
77
|
+
// For sections, we need to look at the directory name in the file path
|
78
|
+
const dirA = a.route.file.path.relative.dir.split('/').pop() || '';
|
79
|
+
const dirB = b.route.file.path.relative.dir.split('/').pop() || '';
|
80
|
+
// Extract order from directory names like "10_b", "20_c"
|
81
|
+
const orderMatchA = dirA.match(/^(\d+)[_-]/);
|
82
|
+
const orderMatchB = dirB.match(/^(\d+)[_-]/);
|
83
|
+
const orderA = orderMatchA ? parseInt(orderMatchA[1], 10) : Number.MAX_SAFE_INTEGER;
|
84
|
+
const orderB = orderMatchB ? parseInt(orderMatchB[1], 10) : Number.MAX_SAFE_INTEGER;
|
85
|
+
if (orderA !== orderB)
|
86
|
+
return orderA - orderB;
|
87
|
+
// Fall back to alphabetical order
|
88
|
+
return dirA.localeCompare(dirB);
|
89
|
+
});
|
90
|
+
for (const page of sortedTopLevelPages) {
|
91
|
+
const pageName = page.route.logical.path[page.route.logical.path.length - 1];
|
92
|
+
const childPath = page.route.logical.path.join('/');
|
93
|
+
const childPages = pagesByParent.get(childPath) || [];
|
94
|
+
if (childPages.length > 0 || FileRouter.routeIsFromIndexFile(page.route)) {
|
95
|
+
// This is a section (has children or is an index page for a subdirectory)
|
96
|
+
const hasIndex = FileRouter.routeIsFromIndexFile(page.route);
|
97
|
+
const section = {
|
98
|
+
type: 'ItemSection',
|
99
|
+
title: Str.titlizeSlug(pageName),
|
100
|
+
pathExp: childPath,
|
101
|
+
isLinkToo: hasIndex,
|
102
|
+
links: [],
|
103
|
+
};
|
104
|
+
// Add direct children as links (sorted by order)
|
105
|
+
const sortedChildPages = [...childPages].sort((a, b) => {
|
106
|
+
const orderA = a.route.logical.order ?? Number.MAX_SAFE_INTEGER;
|
107
|
+
const orderB = b.route.logical.order ?? Number.MAX_SAFE_INTEGER;
|
108
|
+
return orderA - orderB;
|
109
|
+
});
|
110
|
+
for (const childPage of sortedChildPages) {
|
111
|
+
if (!FileRouter.routeIsFromIndexFile(childPage.route)) {
|
112
|
+
section.links.push({
|
113
|
+
type: 'ItemLink',
|
114
|
+
title: Str.titlizeSlug(childPage.route.logical.path[childPage.route.logical.path.length - 1]),
|
115
|
+
pathExp: childPage.route.logical.path.join('/'),
|
116
|
+
});
|
117
|
+
}
|
118
|
+
}
|
119
|
+
// Also add any deeper descendants as flat links
|
120
|
+
const allDescendants = [];
|
121
|
+
for (const [parentPath, pagesInParent] of pagesByParent) {
|
122
|
+
// Check if this path is a descendant (but not direct child)
|
123
|
+
if (parentPath.startsWith(childPath + '/')) {
|
124
|
+
for (const descendantPage of pagesInParent) {
|
125
|
+
if (!FileRouter.routeIsFromIndexFile(descendantPage.route)) {
|
126
|
+
allDescendants.push(descendantPage);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
}
|
131
|
+
// Sort all descendants by their full path order
|
132
|
+
allDescendants.sort((a, b) => {
|
133
|
+
// Compare paths segment by segment, considering order at each level
|
134
|
+
const pathA = a.route.logical.path;
|
135
|
+
const pathB = b.route.logical.path;
|
136
|
+
const minLength = Math.min(pathA.length, pathB.length);
|
137
|
+
for (let i = 0; i < minLength; i++) {
|
138
|
+
const segmentCompare = pathA[i].localeCompare(pathB[i]);
|
139
|
+
if (segmentCompare !== 0)
|
140
|
+
return segmentCompare;
|
141
|
+
}
|
142
|
+
return pathA.length - pathB.length;
|
143
|
+
});
|
144
|
+
for (const descendantPage of allDescendants) {
|
145
|
+
section.links.push({
|
146
|
+
type: 'ItemLink',
|
147
|
+
title: Str.titlizeSlug(descendantPage.route.logical.path[descendantPage.route.logical.path.length - 1]),
|
148
|
+
pathExp: descendantPage.route.logical.path.join('/'),
|
149
|
+
});
|
150
|
+
}
|
151
|
+
if (section.links.length > 0 || section.isLinkToo) {
|
152
|
+
items.push(section);
|
153
|
+
}
|
66
154
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
155
|
+
else {
|
156
|
+
// This is a simple link
|
157
|
+
items.push({
|
158
|
+
type: 'ItemLink',
|
159
|
+
title: Str.titlizeSlug(pageName),
|
160
|
+
pathExp: page.route.logical.path.join('/'),
|
161
|
+
});
|
70
162
|
}
|
71
163
|
}
|
72
|
-
};
|
73
|
-
const pageToItemLink = (page, basePath) => {
|
74
|
-
const pagePathExp = FileRouter.routeToPathExpression(page.route);
|
75
|
-
const pageRelative = FileRouter.makeRelativeUnsafe(page.route, basePath);
|
76
|
-
const pageRelativePathExp = FileRouter.routeToPathExpression(pageRelative);
|
77
|
-
// Remove leading slash for title generation
|
78
|
-
const titlePath = pageRelativePathExp.startsWith('/') ? pageRelativePathExp.slice(1) : pageRelativePathExp;
|
79
|
-
// Use only the last segment for the title
|
80
|
-
const titleSegment = pageRelative.logical.path[pageRelative.logical.path.length - 1] || titlePath;
|
81
|
-
return {
|
82
|
-
type: `ItemLink`,
|
83
|
-
pathExp: pagePathExp.startsWith('/') ? pagePathExp.slice(1) : pagePathExp,
|
84
|
-
title: Str.titlizeSlug(titleSegment),
|
85
|
-
};
|
86
|
-
};
|
87
|
-
const isIndexPage = (page) => {
|
88
|
-
return page.route.file.path.relative.name === 'index';
|
164
|
+
return { items };
|
89
165
|
};
|
90
166
|
//# sourceMappingURL=sidebar.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sidebar.js","sourceRoot":"","sources":["../../../src/api/content/sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"sidebar.js","sourceRoot":"","sources":["../../../src/api/content/sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAwFrC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,UAAsB,EAAgB,EAAE;IACxE,MAAM,YAAY,GAAiB,EAAE,CAAA;IAErC,2CAA2C;IAC3C,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAA;IAEpD,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAE9C,uDAAuD;QACvD,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,SAAQ;QAElD,IAAI,CAAC,kBAAkB,CAAC,GAAG,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AA;YACrB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,wBAAwB;YACxB,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC;gBAChC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;aAC3C,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA"}
|
@@ -10,12 +10,9 @@ export interface Options {
|
|
10
10
|
onChange?: (scanResult: Content.ScanResult) => void;
|
11
11
|
}
|
12
12
|
export interface ProjectDataPages {
|
13
|
-
sidebarIndex: SidebarIndex;
|
13
|
+
sidebarIndex: Content.SidebarIndex;
|
14
14
|
pages: Content.Page[];
|
15
15
|
}
|
16
|
-
export interface SidebarIndex {
|
17
|
-
[pathExpression: string]: Content.Sidebar;
|
18
|
-
}
|
19
16
|
/**
|
20
17
|
* Pages plugin with tree support
|
21
18
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../../src/api/vite/plugins/pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../../src/api/vite/plugins/pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAa3C,eAAO,MAAM,cAAc,8DAA0E,CAAA;AACrG,eAAO,MAAM,kBAAkB,8DAAwF,CAAA;AAEvH,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,kBAAkB,CAAA;IAC/B,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,KAAK,IAAI,CAAA;CACpD;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,OAAO,CAAC,YAAY,CAAA;IAClC,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,CAAA;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,mCAInB,OAAO,KAAG,IAAI,CAAC,MAAM,EAyNvB,CAAA"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Content } from '#api/content/$';
|
2
|
+
import { createNavbar } from '#api/content/navbar';
|
2
3
|
import { polenVirtual } from '#api/vite/vi';
|
3
4
|
import { reportDiagnostics } from '#lib/file-router/diagnostic-reporter';
|
4
5
|
import { FileRouter } from '#lib/file-router/index';
|
@@ -6,7 +7,6 @@ import { debugPolen } from '#singletons/debug';
|
|
6
7
|
import { superjson } from '#singletons/superjson';
|
7
8
|
import mdx from '@mdx-js/rollup';
|
8
9
|
import rehypeShiki from '@shikijs/rehype';
|
9
|
-
import { Tree } from '@wollybeard/kit';
|
10
10
|
import { Arr, Cache, Path, Str } from '@wollybeard/kit';
|
11
11
|
import remarkFrontmatter from 'remark-frontmatter';
|
12
12
|
import remarkGfm from 'remark-gfm';
|
@@ -153,51 +153,13 @@ export const Pages = ({ config, navbarData, onChange, }) => {
|
|
153
153
|
if (navbarData) {
|
154
154
|
const navbarPages = navbarData.get('pages');
|
155
155
|
navbarPages.length = 0; // Clear existing
|
156
|
-
|
157
|
-
|
158
|
-
for (const child of scanResult.tree.root.children) {
|
159
|
-
// Now we have Page objects in the tree
|
160
|
-
const page = child.value;
|
161
|
-
const pathExp = FileRouter.routeToPathExpression(page.route);
|
162
|
-
// Skip hidden pages and index files at root level
|
163
|
-
if (page.metadata.hidden || page.route.logical.path.slice(-1)[0] === 'index') {
|
164
|
-
continue;
|
165
|
-
}
|
166
|
-
// Only include top-level pages (files directly in pages directory)
|
167
|
-
if (page.route.logical.path.length === 1) {
|
168
|
-
const title = Str.titlizeSlug(page.route.logical.path[0]);
|
169
|
-
navbarPages.push({
|
170
|
-
// IMPORTANT: Always ensure paths start with '/' for React Router compatibility.
|
171
|
-
pathExp: pathExp.startsWith('/') ? pathExp : '/' + pathExp,
|
172
|
-
title,
|
173
|
-
});
|
174
|
-
}
|
175
|
-
}
|
176
|
-
}
|
156
|
+
const navbarItems = createNavbar(scanResult.list);
|
157
|
+
navbarPages.push(...navbarItems);
|
177
158
|
}
|
178
159
|
//
|
179
160
|
// ━━ Build Sidebar
|
180
161
|
//
|
181
|
-
const sidebarIndex =
|
182
|
-
// Build sidebar for each top-level directory using the page tree
|
183
|
-
if (scanResult.tree.root) {
|
184
|
-
Tree.visit(scanResult.tree, (node) => {
|
185
|
-
if (!node.value)
|
186
|
-
return;
|
187
|
-
const page = node.value;
|
188
|
-
// Only process top-level directories (pages with logical path length > 1 indicate nested structure)
|
189
|
-
if (page.route.logical.path.length === 1 && node.children.length > 0) {
|
190
|
-
const topLevelDir = page.route.logical.path[0];
|
191
|
-
const pathExp = `/${topLevelDir}`;
|
192
|
-
// Create a subtree for this directory
|
193
|
-
const subtree = Tree.Tree(Tree.Node(page, node.children));
|
194
|
-
// Build sidebar using the new page tree builder
|
195
|
-
const sidebar = Content.buildFromPageTree(subtree, [topLevelDir]);
|
196
|
-
debug(`Built sidebar for ${pathExp}:`, sidebar);
|
197
|
-
sidebarIndex[pathExp] = sidebar;
|
198
|
-
}
|
199
|
-
});
|
200
|
-
}
|
162
|
+
const sidebarIndex = Content.buildSidebarIndex(scanResult);
|
201
163
|
//
|
202
164
|
// ━━ Put It All together
|
203
165
|
//
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../../../src/api/vite/plugins/pages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;
|
1
|
+
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../../../src/api/vite/plugins/pages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,GAAG,MAAM,gBAAgB,CAAA;AAChC,OAAO,WAAW,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,iBAAiB,MAAM,oBAAoB,CAAA;AAClD,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAA;AACrG,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAA;AAavH;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,MAAM,EACN,UAAU,EACV,QAAQ,GACA,EAA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