@marlinjai/clearify 1.6.4 → 1.6.6
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-WT5W333R.js → chunk-BCKH7LNY.js} +1 -1
- package/dist/node/{chunk-7VYQMIW2.js → chunk-NJHE2AWL.js} +42 -8
- package/dist/node/{chunk-7IXPTIHW.js → chunk-SY7KZD5Z.js} +2 -2
- package/dist/node/core/navigation.js +1 -1
- package/dist/node/node/build.js +3 -3
- package/dist/node/node/check.js +2 -2
- package/dist/node/node/index.js +4 -4
- package/dist/node/types/index.d.ts +1 -0
- package/dist/node/vite-plugin/index.js +2 -2
- package/package.json +1 -1
- package/src/client/App.tsx +15 -10
- package/dist/node/{chunk-L24ILRSX.js → chunk-6PUBRHS7.js} +1 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-IBK35HZR.js";
|
|
9
9
|
import {
|
|
10
10
|
buildSectionData
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6PUBRHS7.js";
|
|
12
12
|
|
|
13
13
|
// src/vite-plugin/index.ts
|
|
14
14
|
import { resolve } from "path";
|
|
@@ -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 [
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-SCZZB7OE.js";
|
|
9
9
|
import {
|
|
10
10
|
clearifyPlugin
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NJHE2AWL.js";
|
|
12
12
|
import {
|
|
13
13
|
loadUserConfig,
|
|
14
14
|
resolveConfig,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-IBK35HZR.js";
|
|
17
17
|
import {
|
|
18
18
|
buildSectionData
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-6PUBRHS7.js";
|
|
20
20
|
|
|
21
21
|
// src/node/build.ts
|
|
22
22
|
import { build as viteBuild } from "vite";
|
package/dist/node/node/build.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildSite
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-SY7KZD5Z.js";
|
|
4
4
|
import "../chunk-PRTER35L.js";
|
|
5
5
|
import "../chunk-SCZZB7OE.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-NJHE2AWL.js";
|
|
7
7
|
import "../chunk-B2Q23JW3.js";
|
|
8
8
|
import "../chunk-IBK35HZR.js";
|
|
9
9
|
import "../chunk-V7LLYIRO.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-6PUBRHS7.js";
|
|
11
11
|
import "../chunk-5TD7NQIW.js";
|
|
12
12
|
export {
|
|
13
13
|
buildSite
|
package/dist/node/node/check.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkLinks
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-BCKH7LNY.js";
|
|
4
4
|
import "../chunk-IBK35HZR.js";
|
|
5
5
|
import "../chunk-V7LLYIRO.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-6PUBRHS7.js";
|
|
7
7
|
import "../chunk-5TD7NQIW.js";
|
|
8
8
|
export {
|
|
9
9
|
checkLinks
|
package/dist/node/node/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildSite
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-SY7KZD5Z.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-NJHE2AWL.js";
|
|
11
11
|
import "../chunk-B2Q23JW3.js";
|
|
12
12
|
import {
|
|
13
13
|
init
|
|
14
14
|
} from "../chunk-MWUXPDQK.js";
|
|
15
15
|
import {
|
|
16
16
|
checkLinks
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-BCKH7LNY.js";
|
|
18
18
|
import {
|
|
19
19
|
loadUserConfig,
|
|
20
20
|
resolveConfig
|
|
21
21
|
} from "../chunk-IBK35HZR.js";
|
|
22
22
|
import "../chunk-V7LLYIRO.js";
|
|
23
|
-
import "../chunk-
|
|
23
|
+
import "../chunk-6PUBRHS7.js";
|
|
24
24
|
import "../chunk-5TD7NQIW.js";
|
|
25
25
|
|
|
26
26
|
// src/node/index.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
clearifyPlugin
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-NJHE2AWL.js";
|
|
4
4
|
import "../chunk-B2Q23JW3.js";
|
|
5
5
|
import "../chunk-IBK35HZR.js";
|
|
6
6
|
import "../chunk-V7LLYIRO.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-6PUBRHS7.js";
|
|
8
8
|
import "../chunk-5TD7NQIW.js";
|
|
9
9
|
export {
|
|
10
10
|
clearifyPlugin
|
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>
|
|
@@ -49,6 +49,7 @@ function buildNavigation(docs, basePath = "/") {
|
|
|
49
49
|
const rootDir = basePath === "/" ? "/" : basePath.replace(/\/$/, "");
|
|
50
50
|
const groups = /* @__PURE__ */ new Map();
|
|
51
51
|
for (const doc of docs) {
|
|
52
|
+
if (doc.routePath === rootDir || doc.routePath === "/") continue;
|
|
52
53
|
const dir = dirname(doc.routePath);
|
|
53
54
|
if (!groups.has(dir)) groups.set(dir, []);
|
|
54
55
|
groups.get(dir).push(doc);
|
|
@@ -64,7 +65,6 @@ function buildNavigation(docs, basePath = "/") {
|
|
|
64
65
|
const nav = [];
|
|
65
66
|
const rootFiles = groups.get(rootDir) ?? [];
|
|
66
67
|
for (const doc of rootFiles) {
|
|
67
|
-
if (doc.routePath === rootDir || doc.routePath === "/") continue;
|
|
68
68
|
const item = { label: doc.frontmatter.title, path: doc.routePath };
|
|
69
69
|
if (doc.frontmatter.icon) item.icon = doc.frontmatter.icon;
|
|
70
70
|
nav.push(item);
|