@mintlify/link-rot 3.0.761 → 3.0.763

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.d.ts CHANGED
@@ -66,7 +66,8 @@ export declare class Graph {
66
66
  private edges;
67
67
  private fileResolutionMap;
68
68
  private redirectMap;
69
- constructor(baseDir: string);
69
+ private mintIgnoreGlobs;
70
+ constructor(baseDir: string, mintIgnoreGlobs?: string[]);
70
71
  addNode(label: string): Node;
71
72
  addNodes(labels: string[]): void;
72
73
  setRedirects(redirects: {
package/dist/graph.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isAbsoluteUrl } from '@mintlify/common';
1
+ import { isAbsoluteUrl, isMintIgnored } from '@mintlify/common';
2
2
  import { getFileListWithDirectories } from '@mintlify/prebuild';
3
3
  import { existsSync } from 'fs';
4
4
  import { parse, join, resolve, relative, dirname, basename } from 'path';
@@ -207,13 +207,15 @@ export class Edge {
207
207
  }
208
208
  }
209
209
  export class Graph {
210
- constructor(baseDir) {
210
+ constructor(baseDir, mintIgnoreGlobs = []) {
211
211
  this.baseDir = baseDir;
212
212
  this.nodes = {};
213
213
  this.edges = [];
214
214
  this.fileResolutionMap = new Map();
215
215
  this.redirectMap = new Map();
216
+ this.mintIgnoreGlobs = [];
216
217
  this.baseDir = resolve(baseDir);
218
+ this.mintIgnoreGlobs = mintIgnoreGlobs;
217
219
  }
218
220
  addNode(label) {
219
221
  if (this.nodes[label])
@@ -282,7 +284,8 @@ export class Graph {
282
284
  addAliasNodes() {
283
285
  // TODO move aliases computation to mint config package, since it'll depend on version
284
286
  // for now this is a hacky implementation
285
- const aliases = MdxPath.filterMapInternalPaths(getFileListWithDirectories(this.baseDir));
287
+ const allAliases = MdxPath.filterMapInternalPaths(getFileListWithDirectories(this.baseDir));
288
+ const aliases = allAliases.filter((alias) => !isMintIgnored(alias, this.mintIgnoreGlobs));
286
289
  this.addNodes(aliases);
287
290
  }
288
291
  getNode(label) {
@@ -2,5 +2,7 @@ import { Node } from '../graph.js';
2
2
  export declare const decorateGraphNodeFromPageContent: (graphNode: Node, content: string) => Promise<void>;
3
3
  /**
4
4
  * Get all broken internal links used in the site
5
+ * Files matching .mintignore patterns are excluded from valid link targets,
6
+ * so links pointing to ignored files will be reported as broken.
5
7
  */
6
8
  export declare const getBrokenInternalLinks: (repoPath?: string) => Promise<import("../graph.js").MdxPath[]>;
@@ -7,7 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { coreRemark } from '@mintlify/common';
10
+ import { coreRemark, isMintIgnored } from '@mintlify/common';
11
+ import { getMintIgnore } from '@mintlify/prebuild';
11
12
  import fs from 'fs-extra';
12
13
  import path from 'path';
13
14
  import { visit } from 'unist-util-visit';
@@ -52,19 +53,24 @@ export const decorateGraphNodeFromPageContent = (graphNode, content) => __awaite
52
53
  });
53
54
  /**
54
55
  * Get all broken internal links used in the site
56
+ * Files matching .mintignore patterns are excluded from valid link targets,
57
+ * so links pointing to ignored files will be reported as broken.
55
58
  */
56
59
  export const getBrokenInternalLinks = (repoPath) => __awaiter(void 0, void 0, void 0, function* () {
57
60
  const baseDir = repoPath ? repoPath : process.cwd();
58
- const graph = new Graph(baseDir);
59
- // add nodes for every page or media path in project
60
- const filenames = getLinkPaths(baseDir);
61
+ const mintIgnoreGlobs = yield getMintIgnore(baseDir);
62
+ const graph = new Graph(baseDir, mintIgnoreGlobs);
63
+ // add nodes for every page or media path in project (excluding mintignore'd files)
64
+ const allFilenames = getLinkPaths(baseDir);
65
+ const filenames = allFilenames.filter((file) => !isMintIgnored(file, mintIgnoreGlobs));
61
66
  graph.addNodes(filenames);
62
67
  // pull redirects from docs.json or mint.json if either exist
63
68
  const redirectMappings = yield getRedirects(baseDir);
64
69
  graph.setRedirects(redirectMappings);
65
70
  // add nodes for every link alias in the project
66
71
  graph.addAliasNodes();
67
- const sitePages = getPagePaths(baseDir);
72
+ const allSitePages = getPagePaths(baseDir);
73
+ const sitePages = allSitePages.filter((file) => !isMintIgnored(file, mintIgnoreGlobs));
68
74
  yield Promise.all(sitePages.map((filePath) => __awaiter(void 0, void 0, void 0, function* () {
69
75
  const fileNode = graph.getNode(filePath);
70
76
  if (fileNode) {