@mintlify/previewing 3.1.82 → 3.1.83
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/local-preview/index.js +27 -41
- package/dist/local-preview/listener/generate.js +1 -3
- package/dist/local-preview/listener/index.js +1 -2
- package/dist/local-preview/listener/update.js +1 -3
- package/dist/local-preview/listener/utils.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/local-preview/listener/categorize.d.ts +0 -8
- package/dist/local-preview/listener/categorize.js +0 -193
- package/dist/local-preview/listener/utils/createPage.d.ts +0 -10
- package/dist/local-preview/listener/utils/createPage.js +0 -212
- package/dist/local-preview/listener/utils/types.d.ts +0 -2
- package/dist/local-preview/listener/utils/types.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/previewing",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.83",
|
|
4
4
|
"description": "Preview Mintlify docs locally",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
41
|
-
"@mintlify/prebuild": "1.0.
|
|
41
|
+
"@mintlify/prebuild": "1.0.27",
|
|
42
42
|
"@octokit/rest": "^19.0.5",
|
|
43
43
|
"axios": "^1.2.2",
|
|
44
44
|
"chalk": "^5.1.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@mintlify/eslint-config-typescript": "1.0.7",
|
|
65
65
|
"@mintlify/prettier-config": "1.0.1",
|
|
66
66
|
"@mintlify/ts-config": "1.0.7",
|
|
67
|
-
"@mintlify/validation": "0.1.
|
|
67
|
+
"@mintlify/validation": "0.1.59",
|
|
68
68
|
"@trivago/prettier-plugin-sort-imports": "3.x",
|
|
69
69
|
"@tsconfig/recommended": "1.x",
|
|
70
70
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"prettier": "2.x",
|
|
81
81
|
"typescript": "^4.8.2"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "d354a7173a23eb86d3416785ce3e40cabaacb7ac"
|
|
84
84
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PotentialFileCategory } from './utils/types.js';
|
|
2
|
-
export declare const categorizeFiles: (contentDirectoryPath: string) => Promise<{
|
|
3
|
-
contentFilenames: string[];
|
|
4
|
-
staticFilenames: string[];
|
|
5
|
-
openApiFiles: OpenApiFile[];
|
|
6
|
-
snippets: string[];
|
|
7
|
-
}>;
|
|
8
|
-
export declare const getCategory: (filePath: string) => PotentialFileCategory;
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
38
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
39
|
-
var m = o[Symbol.asyncIterator], i;
|
|
40
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
41
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
42
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
43
|
-
};
|
|
44
|
-
// TODO - put in prebuild package
|
|
45
|
-
import { getFileList } from '@mintlify/prebuild';
|
|
46
|
-
import path from 'path';
|
|
47
|
-
import { getFileExtension, openApiCheck } from './utils.js';
|
|
48
|
-
export var categorizeFiles = function (contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
var contentFilenames, staticFilenames, promises, openApiFiles, snippets, _loop_1, _a, _b, _c, e_1_1;
|
|
50
|
-
var _d, e_1, _e, _f;
|
|
51
|
-
return __generator(this, function (_g) {
|
|
52
|
-
switch (_g.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
contentFilenames = [];
|
|
55
|
-
staticFilenames = [];
|
|
56
|
-
promises = [];
|
|
57
|
-
openApiFiles = [];
|
|
58
|
-
snippets = [];
|
|
59
|
-
_g.label = 1;
|
|
60
|
-
case 1:
|
|
61
|
-
_g.trys.push([1, 6, 7, 12]);
|
|
62
|
-
_loop_1 = function () {
|
|
63
|
-
_f = _c.value;
|
|
64
|
-
_a = false;
|
|
65
|
-
try {
|
|
66
|
-
var filename = _f;
|
|
67
|
-
promises.push((function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
-
var extension, isOpenApi, openApiInfo, fileName;
|
|
69
|
-
return __generator(this, function (_a) {
|
|
70
|
-
switch (_a.label) {
|
|
71
|
-
case 0:
|
|
72
|
-
extension = getFileExtension(filename);
|
|
73
|
-
isOpenApi = false;
|
|
74
|
-
if (!(extension && (extension === 'mdx' || extension === 'md'))) return [3 /*break*/, 1];
|
|
75
|
-
if (filename.startsWith('/_snippets')) {
|
|
76
|
-
snippets.push(filename);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
contentFilenames.push(filename);
|
|
80
|
-
}
|
|
81
|
-
return [3 /*break*/, 4];
|
|
82
|
-
case 1:
|
|
83
|
-
if (!(extension &&
|
|
84
|
-
(extension === 'json' || extension === 'yaml' || extension === 'yml'))) return [3 /*break*/, 3];
|
|
85
|
-
return [4 /*yield*/, openApiCheck(path.join(contentDirectoryPath, filename))];
|
|
86
|
-
case 2:
|
|
87
|
-
openApiInfo = _a.sent();
|
|
88
|
-
isOpenApi = openApiInfo.isOpenApi;
|
|
89
|
-
if (isOpenApi) {
|
|
90
|
-
fileName = path.parse(filename).base;
|
|
91
|
-
openApiFiles.push({
|
|
92
|
-
filename: fileName.substring(0, fileName.lastIndexOf('.')),
|
|
93
|
-
spec: openApiInfo.spec,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return [3 /*break*/, 4];
|
|
97
|
-
case 3:
|
|
98
|
-
if (!filename.endsWith('mint.json') && !isOpenApi) {
|
|
99
|
-
// all other files
|
|
100
|
-
staticFilenames.push(filename);
|
|
101
|
-
}
|
|
102
|
-
_a.label = 4;
|
|
103
|
-
case 4: return [2 /*return*/];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}); })());
|
|
107
|
-
}
|
|
108
|
-
finally {
|
|
109
|
-
_a = true;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
_a = true, _b = __asyncValues(getFileList(contentDirectoryPath));
|
|
113
|
-
_g.label = 2;
|
|
114
|
-
case 2: return [4 /*yield*/, _b.next()];
|
|
115
|
-
case 3:
|
|
116
|
-
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 5];
|
|
117
|
-
_loop_1();
|
|
118
|
-
_g.label = 4;
|
|
119
|
-
case 4: return [3 /*break*/, 2];
|
|
120
|
-
case 5: return [3 /*break*/, 12];
|
|
121
|
-
case 6:
|
|
122
|
-
e_1_1 = _g.sent();
|
|
123
|
-
e_1 = { error: e_1_1 };
|
|
124
|
-
return [3 /*break*/, 12];
|
|
125
|
-
case 7:
|
|
126
|
-
_g.trys.push([7, , 10, 11]);
|
|
127
|
-
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 9];
|
|
128
|
-
return [4 /*yield*/, _e.call(_b)];
|
|
129
|
-
case 8:
|
|
130
|
-
_g.sent();
|
|
131
|
-
_g.label = 9;
|
|
132
|
-
case 9: return [3 /*break*/, 11];
|
|
133
|
-
case 10:
|
|
134
|
-
if (e_1) throw e_1.error;
|
|
135
|
-
return [7 /*endfinally*/];
|
|
136
|
-
case 11: return [7 /*endfinally*/];
|
|
137
|
-
case 12: return [4 /*yield*/, Promise.all(promises)];
|
|
138
|
-
case 13:
|
|
139
|
-
_g.sent();
|
|
140
|
-
return [2 /*return*/, { contentFilenames: contentFilenames, staticFilenames: staticFilenames, openApiFiles: openApiFiles, snippets: snippets }];
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}); };
|
|
144
|
-
var excludedMdFiles = ['readme', 'license', 'contributing', 'contribute'];
|
|
145
|
-
var supportedStaticFileExtensions = [
|
|
146
|
-
'.jpeg',
|
|
147
|
-
'.jpg',
|
|
148
|
-
'.jfif',
|
|
149
|
-
'.pjpeg',
|
|
150
|
-
'.pjp',
|
|
151
|
-
'.png',
|
|
152
|
-
'.svg',
|
|
153
|
-
'.svgz',
|
|
154
|
-
'.ico',
|
|
155
|
-
'.webp',
|
|
156
|
-
'.gif',
|
|
157
|
-
'.apng',
|
|
158
|
-
'.avif',
|
|
159
|
-
'.bmp',
|
|
160
|
-
'.mp4',
|
|
161
|
-
];
|
|
162
|
-
export var getCategory = function (filePath) {
|
|
163
|
-
filePath = filePath.toLowerCase();
|
|
164
|
-
var parsed = path.parse(filePath);
|
|
165
|
-
if (parsed.base === 'mint.json') {
|
|
166
|
-
return 'mintConfig';
|
|
167
|
-
}
|
|
168
|
-
var fileName = parsed.name;
|
|
169
|
-
var extension = parsed.ext;
|
|
170
|
-
if (filePath.startsWith('_snippets') && (extension === '.mdx' || extension === '.md')) {
|
|
171
|
-
return 'snippet';
|
|
172
|
-
}
|
|
173
|
-
else if (extension === '.mdx') {
|
|
174
|
-
return 'page';
|
|
175
|
-
}
|
|
176
|
-
else if (extension === '.md') {
|
|
177
|
-
// Exclude common markdown files people don't want on their docs website
|
|
178
|
-
if (excludedMdFiles.includes(fileName)) {
|
|
179
|
-
throw new Error('Excluded Md File');
|
|
180
|
-
}
|
|
181
|
-
return 'page';
|
|
182
|
-
}
|
|
183
|
-
else if (extension === '.yaml' || extension === '.yml') {
|
|
184
|
-
return 'potentialYamlOpenApiSpec';
|
|
185
|
-
}
|
|
186
|
-
else if (extension === '.json') {
|
|
187
|
-
return 'potentialJsonOpenApiSpec';
|
|
188
|
-
}
|
|
189
|
-
else if (supportedStaticFileExtensions.includes(extension)) {
|
|
190
|
-
return 'staticFile';
|
|
191
|
-
}
|
|
192
|
-
throw new Error('Unsupported File Type, No change enacted');
|
|
193
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const createPage: (pagePath: string, pageContent: string, contentDirectoryPath: string, openApiFiles: OpenApiFile[]) => Promise<{
|
|
2
|
-
pageMetadata: {
|
|
3
|
-
href: string;
|
|
4
|
-
title: string;
|
|
5
|
-
description: string | undefined;
|
|
6
|
-
};
|
|
7
|
-
pageContent: string;
|
|
8
|
-
slug: string;
|
|
9
|
-
}>;
|
|
10
|
-
export default createPage;
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import { slugToTitle, optionallyAddLeadingSlash } from '@mintlify/prebuild';
|
|
49
|
-
import matter from 'gray-matter';
|
|
50
|
-
import isAbsoluteUrl from 'is-absolute-url';
|
|
51
|
-
import { remark } from 'remark';
|
|
52
|
-
import remarkFrontmatter from 'remark-frontmatter';
|
|
53
|
-
import remarkGfm from 'remark-gfm';
|
|
54
|
-
import remarkMath from 'remark-math';
|
|
55
|
-
import remarkMdx from 'remark-mdx';
|
|
56
|
-
import { visit } from 'unist-util-visit';
|
|
57
|
-
var createPage = function (pagePath, pageContent, contentDirectoryPath, openApiFiles) { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
-
var metadata, error_1, slug, defaultTitle, description, _a, title, openApiDescription, pageMetadata;
|
|
59
|
-
return __generator(this, function (_b) {
|
|
60
|
-
switch (_b.label) {
|
|
61
|
-
case 0:
|
|
62
|
-
metadata = matter(pageContent).data;
|
|
63
|
-
_b.label = 1;
|
|
64
|
-
case 1:
|
|
65
|
-
_b.trys.push([1, 3, , 4]);
|
|
66
|
-
return [4 /*yield*/, preParseMdx(pageContent, contentDirectoryPath)];
|
|
67
|
-
case 2:
|
|
68
|
-
pageContent = _b.sent();
|
|
69
|
-
return [3 /*break*/, 4];
|
|
70
|
-
case 3:
|
|
71
|
-
error_1 = _b.sent();
|
|
72
|
-
pageContent = "\uD83D\uDEA7 A parsing error occured. Please contact the owner of this website.";
|
|
73
|
-
return [3 /*break*/, 4];
|
|
74
|
-
case 4:
|
|
75
|
-
slug = pagePath.replace(/\.mdx?$/, '');
|
|
76
|
-
defaultTitle = slugToTitle(slug);
|
|
77
|
-
// Append data from OpenAPI if it exists
|
|
78
|
-
if (metadata === null || metadata === void 0 ? void 0 : metadata.openapi) {
|
|
79
|
-
_a = getOpenApiTitleAndDescription(openApiFiles, metadata === null || metadata === void 0 ? void 0 : metadata.openapi), title = _a.title, openApiDescription = _a.description;
|
|
80
|
-
if (title) {
|
|
81
|
-
defaultTitle = title;
|
|
82
|
-
}
|
|
83
|
-
if (openApiDescription) {
|
|
84
|
-
description = openApiDescription;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
pageMetadata = __assign(__assign({ title: defaultTitle, description: description }, metadata), { href: optionallyAddLeadingSlash(slug) });
|
|
88
|
-
return [2 /*return*/, {
|
|
89
|
-
pageMetadata: pageMetadata,
|
|
90
|
-
pageContent: pageContent,
|
|
91
|
-
slug: removeLeadingSlash(slug),
|
|
92
|
-
}];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); };
|
|
96
|
-
var preParseMdx = function (fileContent, contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
var removeContentDirectoryPath, removeContentDirectoryPaths, file;
|
|
98
|
-
return __generator(this, function (_a) {
|
|
99
|
-
switch (_a.label) {
|
|
100
|
-
case 0:
|
|
101
|
-
removeContentDirectoryPath = function (filePath) {
|
|
102
|
-
var pathArr = createPathArr(filePath);
|
|
103
|
-
var contentDirectoryPathArr = createPathArr(contentDirectoryPath);
|
|
104
|
-
contentDirectoryPathArr.reverse().forEach(function (dir, index) {
|
|
105
|
-
if (pathArr[index] === dir) {
|
|
106
|
-
pathArr.pop();
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
return '/' + pathArr.join('/');
|
|
110
|
-
};
|
|
111
|
-
removeContentDirectoryPaths = function () {
|
|
112
|
-
return function (tree) {
|
|
113
|
-
visit(tree, function (node) {
|
|
114
|
-
if (node == null) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (node.name === 'img' || node.name === 'source') {
|
|
118
|
-
var srcAttrIndex = node.attributes.findIndex(function (attr) { return (attr === null || attr === void 0 ? void 0 : attr.name) === 'src'; });
|
|
119
|
-
var nodeUrl = node.attributes[srcAttrIndex].value;
|
|
120
|
-
if (
|
|
121
|
-
// <img/> component
|
|
122
|
-
srcAttrIndex !== -1 &&
|
|
123
|
-
!isAbsoluteUrl(nodeUrl) &&
|
|
124
|
-
!isDataString(nodeUrl)) {
|
|
125
|
-
node.attributes[srcAttrIndex].value = removeContentDirectoryPath(nodeUrl);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else if (
|
|
129
|
-
// ![]() format
|
|
130
|
-
node.type === 'image' &&
|
|
131
|
-
node.url &&
|
|
132
|
-
!isAbsoluteUrl(node.url) &&
|
|
133
|
-
!isDataString(node.url)) {
|
|
134
|
-
node.url = removeContentDirectoryPath(node.url);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
return tree;
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
return [4 /*yield*/, remark()
|
|
141
|
-
.use(remarkMdx)
|
|
142
|
-
.use(remarkGfm)
|
|
143
|
-
.use(remarkMath)
|
|
144
|
-
.use(remarkFrontmatter, ['yaml', 'toml'])
|
|
145
|
-
.use(removeContentDirectoryPaths)
|
|
146
|
-
.process(fileContent)];
|
|
147
|
-
case 1:
|
|
148
|
-
file = _a.sent();
|
|
149
|
-
return [2 /*return*/, String(file)];
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}); };
|
|
153
|
-
var removeLeadingSlash = function (str) {
|
|
154
|
-
var path = createPathArr(str);
|
|
155
|
-
return path.join('/');
|
|
156
|
-
};
|
|
157
|
-
var createPathArr = function (path) {
|
|
158
|
-
return path.split('/').filter(function (dir) { return dir !== ''; });
|
|
159
|
-
};
|
|
160
|
-
var isDataString = function (str) { return str.startsWith('data:'); };
|
|
161
|
-
var getOpenApiTitleAndDescription = function (openApiFiles, openApiMetaField) {
|
|
162
|
-
var operation = getOpenApiOperationMethodAndEndpoint(openApiFiles, openApiMetaField).operation;
|
|
163
|
-
if (operation == null) {
|
|
164
|
-
return {};
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
title: operation.summary,
|
|
168
|
-
description: operation.description,
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
var getOpenApiOperationMethodAndEndpoint = function (openApiFiles, openApiMetaField) {
|
|
172
|
-
var _a = extractMethodAndEndpoint(openApiMetaField), endpoint = _a.endpoint, method = _a.method, filename = _a.filename;
|
|
173
|
-
var path;
|
|
174
|
-
openApiFiles === null || openApiFiles === void 0 ? void 0 : openApiFiles.forEach(function (file) {
|
|
175
|
-
var openApiFile = file.spec;
|
|
176
|
-
var openApiPath = openApiFile.paths && openApiFile.paths[endpoint];
|
|
177
|
-
var isFilenameOrNone = !filename || filename === file.filename;
|
|
178
|
-
if (openApiPath && isFilenameOrNone) {
|
|
179
|
-
path = openApiPath;
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
if (path == null) {
|
|
183
|
-
return {};
|
|
184
|
-
}
|
|
185
|
-
var operation;
|
|
186
|
-
if (method) {
|
|
187
|
-
operation = path[method.toLowerCase()];
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
var firstOperationKey = Object.keys(path)[0];
|
|
191
|
-
operation = path[firstOperationKey];
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
operation: operation,
|
|
195
|
-
method: method,
|
|
196
|
-
endpoint: endpoint,
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
var extractMethodAndEndpoint = function (openApiMetaField) {
|
|
200
|
-
var methodRegex = /(get|post|put|delete|patch)\s/i;
|
|
201
|
-
var trimmed = openApiMetaField.trim();
|
|
202
|
-
var foundMethod = trimmed.match(methodRegex);
|
|
203
|
-
var startIndexOfMethod = foundMethod ? openApiMetaField.indexOf(foundMethod[0]) : 0;
|
|
204
|
-
var endIndexOfMethod = foundMethod ? startIndexOfMethod + foundMethod[0].length - 1 : 0;
|
|
205
|
-
var filename = openApiMetaField.substring(0, startIndexOfMethod).trim();
|
|
206
|
-
return {
|
|
207
|
-
method: foundMethod ? foundMethod[0].slice(0, -1).toUpperCase() : undefined,
|
|
208
|
-
endpoint: openApiMetaField.substring(endIndexOfMethod).trim(),
|
|
209
|
-
filename: filename ? filename : undefined,
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
export default createPage;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|