@mintlify/link-rot 3.0.895 → 3.0.897

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
@@ -85,7 +85,9 @@ export declare class Graph {
85
85
  addEdgesBetweenNodes(): void;
86
86
  precomputeFileResolutions(): void;
87
87
  private getHeadingSlugsForPath;
88
- getBrokenInternalLinks(): MdxPath[];
88
+ getBrokenInternalLinks(options?: {
89
+ checkAnchors?: boolean;
90
+ }): MdxPath[];
89
91
  getAllInternalPaths(): string[];
90
92
  }
91
93
  export {};
package/dist/graph.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isAbsoluteUrl, isMintIgnored } from '@mintlify/common';
1
+ import { cleanHeadingId, 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';
@@ -360,7 +360,7 @@ export class Graph {
360
360
  return indexNode.headingSlugs;
361
361
  return undefined;
362
362
  }
363
- getBrokenInternalLinks() {
363
+ getBrokenInternalLinks(options) {
364
364
  if (this.fileResolutionMap.size === 0) {
365
365
  this.precomputeFileResolutions();
366
366
  }
@@ -390,8 +390,8 @@ export class Graph {
390
390
  if (!hasExistingFile && !hasValidRedirect) {
391
391
  brokenLinks.push(path);
392
392
  }
393
- else if (path.anchorLink) {
394
- const anchor = path.anchorLink.slice(1);
393
+ else if ((options === null || options === void 0 ? void 0 : options.checkAnchors) && path.anchorLink) {
394
+ const anchor = cleanHeadingId(path.anchorLink.slice(1));
395
395
  const headingSlugs = this.getHeadingSlugsForPath(pathString, nodeSet);
396
396
  if (headingSlugs && !headingSlugs.has(anchor)) {
397
397
  brokenLinks.push(path);
@@ -7,4 +7,6 @@ export declare const decorateGraphNodeFromPageContent: (graphNode: Node, content
7
7
  * Files matching .mintignore patterns are excluded from valid link targets,
8
8
  * so links pointing to ignored files will be reported as broken.
9
9
  */
10
- export declare const getBrokenInternalLinks: (repoPath?: string) => Promise<import("../graph.js").MdxPath[]>;
10
+ export declare const getBrokenInternalLinks: (repoPath?: string, options?: {
11
+ checkAnchors?: boolean;
12
+ }) => Promise<import("../graph.js").MdxPath[]>;
@@ -7,7 +7,7 @@ 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, isMintIgnored, remarkComponentIds, remarkExtractTableOfContents, } from '@mintlify/common';
10
+ import { cleanHeadingId, coreRemark, isMintIgnored, remarkComponentIds, remarkExtractTableOfContents, } from '@mintlify/common';
11
11
  import { getMintIgnore } from '@mintlify/prebuild';
12
12
  import fs from 'fs-extra';
13
13
  import path from 'path';
@@ -20,7 +20,7 @@ import { getRedirects } from './getRedirects.js';
20
20
  export const flattenTableOfContentsSlugs = (sections) => {
21
21
  const slugs = new Set();
22
22
  for (const section of sections) {
23
- slugs.add(section.slug);
23
+ slugs.add(cleanHeadingId(section.slug));
24
24
  for (const slug of flattenTableOfContentsSlugs(section.children)) {
25
25
  slugs.add(slug);
26
26
  }
@@ -76,7 +76,7 @@ export const decorateGraphNodeFromPageContent = (graphNode, content) => __awaite
76
76
  * Files matching .mintignore patterns are excluded from valid link targets,
77
77
  * so links pointing to ignored files will be reported as broken.
78
78
  */
79
- export const getBrokenInternalLinks = (repoPath) => __awaiter(void 0, void 0, void 0, function* () {
79
+ export const getBrokenInternalLinks = (repoPath, options) => __awaiter(void 0, void 0, void 0, function* () {
80
80
  const baseDir = repoPath ? repoPath : process.cwd();
81
81
  const mintIgnoreGlobs = yield getMintIgnore(baseDir);
82
82
  const graph = new Graph(baseDir, mintIgnoreGlobs);
@@ -121,5 +121,5 @@ export const getBrokenInternalLinks = (repoPath) => __awaiter(void 0, void 0, vo
121
121
  })));
122
122
  // Precompute file resolutions before checking for broken links
123
123
  graph.precomputeFileResolutions();
124
- return graph.getBrokenInternalLinks();
124
+ return graph.getBrokenInternalLinks(options);
125
125
  });