Skip to content

Commit b3cbee8

Browse files
authored
Fix validation of custom IDs/slugs (#82)
1 parent 876cb50 commit b3cbee8

File tree

26 files changed

+644
-153
lines changed

26 files changed

+644
-153
lines changed

.changeset/hot-rabbits-sing.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'starlight-links-validator': patch
3+
---
4+
5+
Fixes regresion introduced in version [`0.14.0`](https://github.com/HiDeoo/starlight-links-validator/releases/tag/starlight-links-validator%400.14.0) of the plugin regarding validation of links to pages with [custom IDs/slugs](https://docs.astro.build/en/guides/content-collections/#defining-custom-ids).
6+
7+
Note that you must use at least Astro version [`5.1.1`](https://github.com/withastro/astro/releases/tag/astro%405.1.1) to benefit from this fix.

docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"@astrojs/starlight": "^0.30.2",
1717
"@hideoo/starlight-plugins-docs-components": "^0.3.0",
18-
"astro": "^5.0.9",
18+
"astro": "^5.1.1",
1919
"sharp": "^0.33.5"
2020
},
2121
"engines": {

example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@astrojs/starlight": "^0.30.2",
17-
"astro": "^5.0.9",
17+
"astro": "^5.1.1",
1818
"sharp": "^0.33.5",
1919
"starlight-links-validator": "workspace:*"
2020
},

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@hideoo/eslint-config": "^4.0.0",
1919
"@hideoo/prettier-config": "^2.0.0",
2020
"@hideoo/tsconfig": "^2.0.1",
21-
"astro": "^5.0.9",
21+
"astro": "^5.1.1",
2222
"eslint": "^9.17.0",
2323
"prettier": "^3.4.2",
2424
"typescript": "^5.7.2"

packages/starlight-links-validator/tests/base-path.test.ts

+1-16
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ test('validates links when the `base` Astro option is set', async () => {
99

1010
expect(status).toBe('error')
1111

12-
/**
13-
* Due to a regression in Astro v5 + Content Layer, pages with custom IDs/slugs can no longer be validated.
14-
* @see https://github.com/withastro/astro/issues/12778
15-
*/
16-
// expectValidationErrorCount(output, 16, 1)
17-
expectValidationErrorCount(output, 20, 1)
12+
expectValidationErrorCount(output, 16, 1)
1813

1914
expectValidationErrors(output, 'test/test/', [
2015
['/guides/example', ValidationErrorType.InvalidLink],
@@ -27,16 +22,6 @@ test('validates links when the `base` Astro option is set', async () => {
2722
['/test/guides/example/#unknown', ValidationErrorType.InvalidHash],
2823
['/favicon.svg', ValidationErrorType.InvalidLink],
2924
['/guidelines/dummy.pdf', ValidationErrorType.InvalidLink],
30-
31-
/**
32-
* Due to a regression in Astro v5 + Content Layer, pages with custom IDs/slugs can no longer be validated.
33-
* @see https://github.com/withastro/astro/issues/12778
34-
*/
35-
['/test/release/@pkg/v0.1.0', ValidationErrorType.InvalidLink],
36-
['/test/release/@pkg/v0.1.0/', ValidationErrorType.InvalidLink],
37-
['/test/release/@pkg/v0.1.0#some-content', ValidationErrorType.InvalidLink],
38-
['/test/release/@pkg/v0.1.0/#some-content', ValidationErrorType.InvalidLink],
39-
4025
['/release/@pkg/v0.1.0', ValidationErrorType.InvalidLink],
4126
['/release/@pkg/v0.1.0/', ValidationErrorType.InvalidLink],
4227
['/release/@pkg/v0.1.0#some-content', ValidationErrorType.InvalidLink],

packages/starlight-links-validator/tests/basics.test.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,9 @@ test('builds with no links', async () => {
1111
})
1212

1313
test('builds with valid links', async () => {
14-
const { status, output } = await buildFixture('valid-links')
14+
const { status } = await buildFixture('valid-links')
1515

16-
/**
17-
* Due to a regression in Astro v5 + Content Layer, pages with custom IDs/slugs can no longer be validated.
18-
* @see https://github.com/withastro/astro/issues/12778
19-
*/
20-
// expect(status).toBe('success')
21-
expect(status).toBe('error')
22-
expectValidationErrorCount(output, 1, 1)
23-
expectValidationErrors(output, '/', [['/release/@pkg/v0.1.0', ValidationErrorType.InvalidLink]])
16+
expect(status).toBe('success')
2417
})
2518

2619
test('does not build with invalid links', async () => {

packages/starlight-links-validator/tests/fixtures/base-path/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/custom-ids/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"remark-custom-heading-id": "^2.0.0",
88
"starlight-links-validator": "workspace:*"
99
},

packages/starlight-links-validator/tests/fixtures/exclude/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/fallback-invalid-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/fallback-prevent-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/fallback-root-invalid-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/fallback-root-valid-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/fallback-valid-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/inconsistent-locale-root/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/inconsistent-locale/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/invalid-hashes-invalid-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/invalid-hashes-valid-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/invalid-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/no-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/relative-ignore/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/src-dir/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/trailing-always/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/trailing-never/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

packages/starlight-links-validator/tests/fixtures/valid-links/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@astrojs/starlight": "^0.30.2",
6-
"astro": "^5.0.9",
6+
"astro": "^5.1.1",
77
"starlight-links-validator": "workspace:*"
88
},
99
"private": true

0 commit comments

Comments
 (0)