@marlinjai/clearify 1.6.3 → 1.6.5
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/dist/node/{chunk-7IXPTIHW.js → chunk-E3KDK3VB.js} +1 -1
- package/dist/node/{chunk-7VYQMIW2.js → chunk-WAWXVHUA.js} +41 -7
- package/dist/node/node/build.js +2 -2
- package/dist/node/node/index.js +2 -2
- package/dist/node/types/index.d.ts +1 -0
- package/dist/node/vite-plugin/index.js +1 -1
- package/package.json +1 -1
- package/src/client/App.tsx +15 -10
- package/src/theme/Sidebar.tsx +1 -1
|
@@ -26,6 +26,16 @@ var VIRTUAL_MERMAID_SVGS = "virtual:clearify/mermaid-svgs";
|
|
|
26
26
|
var RESOLVED_VIRTUAL_MERMAID_SVGS = "\0" + VIRTUAL_MERMAID_SVGS;
|
|
27
27
|
var VIRTUAL_OPENAPI_SPEC = "virtual:clearify/openapi-spec";
|
|
28
28
|
var RESOLVED_VIRTUAL_OPENAPI_SPEC = "\0" + VIRTUAL_OPENAPI_SPEC;
|
|
29
|
+
function findFirstNavPath(items) {
|
|
30
|
+
for (const item of items) {
|
|
31
|
+
if (item.path) return item.path;
|
|
32
|
+
if (item.children) {
|
|
33
|
+
const found = findFirstNavPath(item.children);
|
|
34
|
+
if (found) return found;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
29
39
|
function clearifyPlugin(options = {}) {
|
|
30
40
|
let config;
|
|
31
41
|
let userRoot;
|
|
@@ -102,20 +112,44 @@ function clearifyPlugin(options = {}) {
|
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
114
|
}
|
|
115
|
+
for (const sectionNav of allSectionNavigations) {
|
|
116
|
+
const bp = sectionNav.basePath;
|
|
117
|
+
const hasRoute = allRoutes.some(
|
|
118
|
+
(r) => r.path === bp || r.path === `${bp}/*`
|
|
119
|
+
);
|
|
120
|
+
if (!hasRoute) {
|
|
121
|
+
const firstPath = findFirstNavPath(sectionNav.navigation);
|
|
122
|
+
if (firstPath) {
|
|
123
|
+
allRoutes.push({
|
|
124
|
+
path: bp,
|
|
125
|
+
filePath: "",
|
|
126
|
+
frontmatter: { title: sectionNav.label },
|
|
127
|
+
sectionId: sectionNav.id,
|
|
128
|
+
redirectTo: firstPath
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
105
133
|
}
|
|
106
134
|
function generateRoutesCode() {
|
|
107
135
|
const imports = [];
|
|
108
136
|
const routeEntries = [];
|
|
109
137
|
allRoutes.forEach((route, i) => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
138
|
+
if (route.redirectTo) {
|
|
139
|
+
routeEntries.push(
|
|
140
|
+
` { path: ${JSON.stringify(route.path)}, redirectTo: ${JSON.stringify(route.redirectTo)} }`
|
|
141
|
+
);
|
|
113
142
|
} else {
|
|
114
|
-
|
|
143
|
+
const varName = `Route${i}`;
|
|
144
|
+
if (route.componentPath) {
|
|
145
|
+
imports.push(`const ${varName} = () => import('${route.componentPath}');`);
|
|
146
|
+
} else {
|
|
147
|
+
imports.push(`const ${varName} = () => import(/* @vite-ignore */ '${route.filePath}');`);
|
|
148
|
+
}
|
|
149
|
+
routeEntries.push(
|
|
150
|
+
` { path: ${JSON.stringify(route.path)}, component: ${varName}, frontmatter: ${JSON.stringify(route.frontmatter)} }`
|
|
151
|
+
);
|
|
115
152
|
}
|
|
116
|
-
routeEntries.push(
|
|
117
|
-
` { path: ${JSON.stringify(route.path)}, component: ${varName}, frontmatter: ${JSON.stringify(route.frontmatter)} }`
|
|
118
|
-
);
|
|
119
153
|
});
|
|
120
154
|
return `${imports.join("\n")}
|
|
121
155
|
export default [
|
package/dist/node/node/build.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildSite
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-E3KDK3VB.js";
|
|
4
4
|
import "../chunk-PRTER35L.js";
|
|
5
5
|
import "../chunk-SCZZB7OE.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-WAWXVHUA.js";
|
|
7
7
|
import "../chunk-B2Q23JW3.js";
|
|
8
8
|
import "../chunk-IBK35HZR.js";
|
|
9
9
|
import "../chunk-V7LLYIRO.js";
|
package/dist/node/node/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildSite
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-E3KDK3VB.js";
|
|
4
4
|
import {
|
|
5
5
|
remarkMermaidToComponent
|
|
6
6
|
} from "../chunk-PRTER35L.js";
|
|
7
7
|
import "../chunk-SCZZB7OE.js";
|
|
8
8
|
import {
|
|
9
9
|
clearifyPlugin
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-WAWXVHUA.js";
|
|
11
11
|
import "../chunk-B2Q23JW3.js";
|
|
12
12
|
import {
|
|
13
13
|
init
|
package/package.json
CHANGED
package/src/client/App.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { BrowserRouter, Routes, Route, useLocation } from 'react-router-dom';
|
|
2
|
+
import { BrowserRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom';
|
|
3
3
|
import { MDXProvider } from '@mdx-js/react';
|
|
4
4
|
// @ts-expect-error virtual module
|
|
5
5
|
import routes from 'virtual:clearify/routes';
|
|
@@ -15,8 +15,9 @@ import '../theme/styles/globals.css';
|
|
|
15
15
|
|
|
16
16
|
interface RouteEntry {
|
|
17
17
|
path: string;
|
|
18
|
-
component
|
|
19
|
-
frontmatter
|
|
18
|
+
component?: () => Promise<any>;
|
|
19
|
+
frontmatter?: { title?: string; description?: string };
|
|
20
|
+
redirectTo?: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function PageWrapper({ loader, fallbackFrontmatter }: { loader: () => Promise<any>; fallbackFrontmatter: any }) {
|
|
@@ -77,13 +78,17 @@ function AppRoutes() {
|
|
|
77
78
|
return (
|
|
78
79
|
<Layout config={config} sections={sections}>
|
|
79
80
|
<Routes>
|
|
80
|
-
{(routes as RouteEntry[]).map((route) =>
|
|
81
|
-
|
|
82
|
-
key={route.path}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
{(routes as RouteEntry[]).map((route) =>
|
|
82
|
+
route.redirectTo ? (
|
|
83
|
+
<Route key={route.path} path={route.path} element={<Navigate to={route.redirectTo} replace />} />
|
|
84
|
+
) : (
|
|
85
|
+
<Route
|
|
86
|
+
key={route.path}
|
|
87
|
+
path={route.path}
|
|
88
|
+
element={<PageWrapper loader={route.component!} fallbackFrontmatter={route.frontmatter} />}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
)}
|
|
87
92
|
<Route path="*" element={<NotFound />} />
|
|
88
93
|
</Routes>
|
|
89
94
|
</Layout>
|
package/src/theme/Sidebar.tsx
CHANGED
|
@@ -254,7 +254,7 @@ export function Sidebar({ sections, open, onClose }: SidebarProps) {
|
|
|
254
254
|
setSelectedSectionId(id);
|
|
255
255
|
const section = sections.find((s) => s.id === id);
|
|
256
256
|
if (section) {
|
|
257
|
-
const firstPath =
|
|
257
|
+
const firstPath = section.basePath ?? findFirstPath(section.navigation);
|
|
258
258
|
if (firstPath && firstPath !== location.pathname) {
|
|
259
259
|
navigate(firstPath);
|
|
260
260
|
}
|