validate-mdx-links 1.2.0 → 1.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # validate-mdx-links
2
2
 
3
+ ## 1.2.1
4
+
5
+ - Fix install command in README (use `bun`, not `npm`).
6
+
3
7
  ## 1.2.0
4
8
 
5
9
  ### Features
package/README.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # validate-mdx-links
2
2
 
3
- Wraps `next-validate-link` with heuristics for false positives.
4
- Handles relative links, with and without `.mdx` extension, and treats `page.mdx` (Next.js App Router) as an index file.
3
+ Validates internal links in MDX files. Wraps `next-validate-link` with heuristics that cut false positives for relative paths, file extensions, and framework-specific routing.
4
+
5
+ ## Supported Frameworks
6
+
7
+ - **Next.js** — App Router (`app/`) and Pages Router (`pages/`)
8
+ - **Fumadocs** — content-directory scanning (`content/`)
9
+ - **TanStack Router** — `src/routes/` with `$params`, `_layout` prefixes, `[.]` literal dots
10
+
11
+ Detection reads `package.json` dependencies first, then falls back to directory heuristics.
5
12
 
6
13
  ## Install
7
14
 
@@ -15,11 +22,22 @@ bun add -D validate-mdx-links
15
22
  validate-mdx-links --files "content/**/*.mdx" --verbose
16
23
  ```
17
24
 
18
- - `--cwd` defaults to `process.cwd()`
19
- - `--verbose` prints every scanned route
20
- - exits `1` on broken links, `0` otherwise
25
+ | Flag | Default | Description |
26
+ |------|---------|-------------|
27
+ | `--files` | | Glob pattern for MDX files to validate |
28
+ | `--content-dir` | — | Content directory for URL scanning; sets `--files` to `${contentDir}/**/*.mdx` when omitted |
29
+ | `--cwd` | `process.cwd()` | Working directory |
30
+ | `--verbose` | `false` | Print every scanned route |
31
+
32
+ Exits `1` on broken links, `0` otherwise.
21
33
 
22
- Relative links lose `.mdx` in MDX or JSX. The CLI checks `./foo`, `./foo.mdx`, and `../foo/page.mdx` before complaining.
34
+ ### Relative links
35
+
36
+ The CLI resolves relative links (`./sibling`, `../other-dir/page`) against the content directory. It checks multiple path variants — with and without `.mdx`, and with `page.mdx` (App Router index) — before reporting a broken link.
37
+
38
+ ### Heading fragments
39
+
40
+ Heading IDs follow GitHub Slugger conventions (duplicate tracking, non-ASCII preservation). Links like `./page#section` validate against extracted headings.
23
41
 
24
42
  ## API
25
43
 
@@ -29,8 +47,14 @@ import { validateMdxLinks, printErrors } from "validate-mdx-links";
29
47
  const errors = await validateMdxLinks({
30
48
  cwd: "/path/to/docs",
31
49
  files: "content/**/*.mdx",
50
+ contentDir: "content",
32
51
  verbose: true,
33
52
  });
53
+
54
+ if (errors.length) {
55
+ printErrors(errors);
56
+ process.exit(1);
57
+ }
34
58
  ```
35
59
 
36
- You get an array of `{ file, detected }`. Pass it to `printErrors` or build your own reporter.
60
+ `validateMdxLinks` returns `ValidationResult[]`; each entry has `file` and `detected` fields. Pass the array to `printErrors` or build a custom reporter.
package/dist/index.js CHANGED
@@ -182,6 +182,7 @@ function buildContentScanResult(contentDir, cwd, verbose, deps) {
182
182
  return { urls, fallbackUrls };
183
183
  }
184
184
  export async function validateMdxLinks({ cwd = process.cwd(), files: filesGlob, verbose = false, contentDir, }) {
185
+ cwd = resolve(cwd);
185
186
  const originalCwd = process.cwd();
186
187
  process.chdir(cwd);
187
188
  const files = globSync(filesGlob);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "validate-mdx-links",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -263,6 +263,7 @@ export async function validateMdxLinks({
263
263
  verbose = false,
264
264
  contentDir,
265
265
  }: ValidateMdxLinksOptions): Promise<ValidationResult[]> {
266
+ cwd = resolve(cwd);
266
267
  const originalCwd = process.cwd();
267
268
  process.chdir(cwd);
268
269