validate-mdx-links 1.0.8 → 1.1.0
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/index.js +13 -0
- package/package.json +2 -2
- package/src/index.ts +15 -0
package/dist/index.js
CHANGED
|
@@ -39,6 +39,19 @@ export async function validateMdxLinks({ cwd = process.cwd(), files: filesGlob,
|
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
// if the file is called index.mdx and is in content dir, it turns out
|
|
43
|
+
// both `./dirname/foo` and `./foo` links work and point to the same file and
|
|
44
|
+
if (basename(file) === "index.mdx") {
|
|
45
|
+
const dir = basename(dirname(file));
|
|
46
|
+
const isSameDir = dir === basename(dirname(link));
|
|
47
|
+
if (isSameDir) {
|
|
48
|
+
const path = resolve(dirname(file), "..", `${link}.mdx`);
|
|
49
|
+
if (await fileExists(path)) {
|
|
50
|
+
// file exists, the error is a false positive
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
42
55
|
// relative links can lose their .mdx extension
|
|
43
56
|
if (!link.endsWith(".mdx")) {
|
|
44
57
|
const dest = resolve(dirname(file), `${link}.mdx`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "validate-mdx-links",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://haspar.us"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"next-validate-link": "
|
|
24
|
+
"next-validate-link": "1.4.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^22.10.7",
|
package/src/index.ts
CHANGED
|
@@ -72,6 +72,21 @@ export async function validateMdxLinks({
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// if the file is called index.mdx and is in content dir, it turns out
|
|
76
|
+
// both `./dirname/foo` and `./foo` links work and point to the same file and
|
|
77
|
+
if (basename(file) === "index.mdx") {
|
|
78
|
+
const dir = basename(dirname(file));
|
|
79
|
+
const isSameDir = dir === basename(dirname(link));
|
|
80
|
+
|
|
81
|
+
if (isSameDir) {
|
|
82
|
+
const path = resolve(dirname(file), "..", `${link}.mdx`);
|
|
83
|
+
if (await fileExists(path)) {
|
|
84
|
+
// file exists, the error is a false positive
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
// relative links can lose their .mdx extension
|
|
76
91
|
if (!link.endsWith(".mdx")) {
|
|
77
92
|
const dest = resolve(dirname(file), `${link}.mdx`);
|