@mintlify/previewing 4.0.1670 → 4.0.1672
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.
|
@@ -2,7 +2,7 @@ import fse from 'fs-extra';
|
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { generatePages } from '../local-preview/export-next.js';
|
|
5
|
-
import { withIndexRouteAliases, writeStaticUserInfo } from '../local-preview/export.js';
|
|
5
|
+
import { getDocsNavRoutes, withIndexRouteAliases, writeStaticUserInfo, } from '../local-preview/export.js';
|
|
6
6
|
import { getGroupFilteredRoutes } from '../local-preview/getGroupFilteredRoutes.js';
|
|
7
7
|
describe('getGroupFilteredRoutes', () => {
|
|
8
8
|
it('prunes routes outside the selected groups', () => {
|
|
@@ -22,6 +22,19 @@ describe('getGroupFilteredRoutes', () => {
|
|
|
22
22
|
expect(routes).toEqual(['/', '/index', '/quickstart', '/authenticated']);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
+
describe('getDocsNavRoutes', () => {
|
|
26
|
+
it('skips openapi endpoint strings', () => {
|
|
27
|
+
expect(getDocsNavRoutes({
|
|
28
|
+
tabs: [
|
|
29
|
+
{
|
|
30
|
+
tab: 'API',
|
|
31
|
+
openapi: 'openapi/api.json',
|
|
32
|
+
pages: ['intro', 'GET /projects/{projectId}/errors', 'openapi.json POST /items'],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
})).toEqual(['/intro']);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
25
38
|
describe('withIndexRouteAliases', () => {
|
|
26
39
|
it('adds the parent route for nested index pages', () => {
|
|
27
40
|
expect(withIndexRouteAliases(['/', '/index', '/agent/index', '/agent/slack'])).toEqual([
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { NavigationConfig } from '@mintlify/validation';
|
|
1
2
|
import { ArgumentsCamelCase } from 'yargs';
|
|
2
3
|
export declare const withIndexRouteAliases: (routes: string[]) => string[];
|
|
4
|
+
export declare const getDocsNavRoutes: (navigation: NavigationConfig) => string[];
|
|
3
5
|
export declare function writeStaticUserInfo(tmpDir: string, groups: string[] | undefined): Promise<void>;
|
|
4
6
|
export declare function writeLlmsTxt(tmpDir: string, routes: string[], basePath?: string): Promise<void>;
|
|
5
7
|
export declare const exportSite: (argv: ArgumentsCamelCase) => Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getAllPathsInDecoratedNav, getAllPathsInDocsNav } from '@mintlify/common';
|
|
2
|
+
import { getAllPathsInDecoratedNav, getAllPathsInDocsNav, potentiallyParseOpenApiString, } from '@mintlify/common';
|
|
3
3
|
import { prebuild } from '@mintlify/prebuild';
|
|
4
4
|
import fse, { pathExists } from 'fs-extra';
|
|
5
5
|
import os from 'os';
|
|
@@ -56,6 +56,9 @@ async function fatal(message) {
|
|
|
56
56
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
57
57
|
process.exit(1);
|
|
58
58
|
}
|
|
59
|
+
export const getDocsNavRoutes = (navigation) => getAllPathsInDocsNav(navigation)
|
|
60
|
+
.filter((navPath) => potentiallyParseOpenApiString(navPath) === undefined)
|
|
61
|
+
.map((navPath) => `/${navPath}`);
|
|
59
62
|
async function collectRoutes(groups) {
|
|
60
63
|
const shouldFilterByGroups = groups !== undefined && groups.length > 0;
|
|
61
64
|
const routes = new Set(shouldFilterByGroups ? [] : ['/']);
|
|
@@ -65,8 +68,8 @@ async function collectRoutes(groups) {
|
|
|
65
68
|
}
|
|
66
69
|
const config = await fse.readJson(docsConfigPath);
|
|
67
70
|
if (!shouldFilterByGroups && config.navigation) {
|
|
68
|
-
for (const
|
|
69
|
-
routes.add(
|
|
71
|
+
for (const route of getDocsNavRoutes(config.navigation)) {
|
|
72
|
+
routes.add(route);
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
// Also collect routes from the generated decorated nav, which includes OpenAPI/AsyncAPI
|