@mintlify/link-rot 3.0.893 → 3.0.894
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/graph.js
CHANGED
|
@@ -341,6 +341,7 @@ export class Graph {
|
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
343
|
getHeadingSlugsForPath(pathString, nodeSet) {
|
|
344
|
+
var _a;
|
|
344
345
|
const resolvedFiles = this.fileResolutionMap.get(pathString);
|
|
345
346
|
if (resolvedFiles) {
|
|
346
347
|
for (const file of resolvedFiles) {
|
|
@@ -354,6 +355,9 @@ export class Graph {
|
|
|
354
355
|
const directNode = this.nodes[pathString];
|
|
355
356
|
if (directNode && directNode.headingSlugs !== null)
|
|
356
357
|
return directNode.headingSlugs;
|
|
358
|
+
const indexNode = (_a = this.nodes[`${pathString}/index.mdx`]) !== null && _a !== void 0 ? _a : this.nodes[`${pathString}/index.md`];
|
|
359
|
+
if (indexNode && indexNode.headingSlugs !== null)
|
|
360
|
+
return indexNode.headingSlugs;
|
|
357
361
|
return undefined;
|
|
358
362
|
}
|
|
359
363
|
getBrokenInternalLinks() {
|
|
@@ -14,6 +14,7 @@ import path from 'path';
|
|
|
14
14
|
import { visit } from 'unist-util-visit';
|
|
15
15
|
import { Graph, Wrapper } from '../graph.js';
|
|
16
16
|
import { getLinkPaths, getPagePaths } from '../prebuild.js';
|
|
17
|
+
import { getNavigationHrefs } from './getNavigationHrefs.js';
|
|
17
18
|
import { getOpenApiPagePaths } from './getOpenApiPagePaths.js';
|
|
18
19
|
import { getRedirects } from './getRedirects.js';
|
|
19
20
|
export const flattenTableOfContentsSlugs = (sections) => {
|
|
@@ -96,6 +97,14 @@ export const getBrokenInternalLinks = (repoPath) => __awaiter(void 0, void 0, vo
|
|
|
96
97
|
catch (err) {
|
|
97
98
|
console.warn(`Warning: Failed to extract OpenAPI page paths: ${err}`);
|
|
98
99
|
}
|
|
100
|
+
const navResult = yield getNavigationHrefs(baseDir);
|
|
101
|
+
if (navResult) {
|
|
102
|
+
const configNode = graph.addNode(navResult.configFile);
|
|
103
|
+
for (const href of navResult.hrefs) {
|
|
104
|
+
const normalized = href === '/' || href === '' ? '/index' : href.replace(/^\/#/, '/index#');
|
|
105
|
+
configNode.addPath(normalized);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
99
108
|
const allSitePages = getPagePaths(baseDir);
|
|
100
109
|
const sitePages = allSitePages.filter((file) => !isMintIgnored(file, mintIgnoreGlobs));
|
|
101
110
|
yield Promise.all(sitePages.map((filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import fs from 'fs-extra';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
const collectHrefs = (obj) => {
|
|
13
|
+
if (typeof obj !== 'object' || obj === null)
|
|
14
|
+
return [];
|
|
15
|
+
if (Array.isArray(obj))
|
|
16
|
+
return obj.flatMap(collectHrefs);
|
|
17
|
+
const record = obj;
|
|
18
|
+
const hrefs = [];
|
|
19
|
+
if (typeof record.href === 'string') {
|
|
20
|
+
hrefs.push(record.href);
|
|
21
|
+
}
|
|
22
|
+
for (const value of Object.values(record)) {
|
|
23
|
+
hrefs.push(...collectHrefs(value));
|
|
24
|
+
}
|
|
25
|
+
return hrefs;
|
|
26
|
+
};
|
|
27
|
+
export const getNavigationHrefs = (baseDir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
let configJson;
|
|
29
|
+
let configFile;
|
|
30
|
+
if (fs.existsSync(path.join(baseDir, 'docs.json'))) {
|
|
31
|
+
configJson = yield fs.readJSON(path.join(baseDir, 'docs.json'));
|
|
32
|
+
configFile = 'docs.json';
|
|
33
|
+
}
|
|
34
|
+
else if (fs.existsSync(path.join(baseDir, 'mint.json'))) {
|
|
35
|
+
configJson = yield fs.readJSON(path.join(baseDir, 'mint.json'));
|
|
36
|
+
configFile = 'mint.json';
|
|
37
|
+
}
|
|
38
|
+
if (!(configJson === null || configJson === void 0 ? void 0 : configJson.navigation) || !configFile)
|
|
39
|
+
return undefined;
|
|
40
|
+
return { hrefs: collectHrefs(configJson.navigation), configFile };
|
|
41
|
+
});
|