-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add errors for relative internal links
- Loading branch information
Showing
12 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...inks-validator/tests/fixtures/basics-invalid-links/src/content/docs/relative.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Relative | ||
--- | ||
|
||
- [Link to the same page](.) | ||
- [Link to the same page with its name](./relative) | ||
- [Link to another page in the same directory](./test) | ||
- [Link to another page in another directory](./guides/example) | ||
- [Link to another page in a parent directory](../test) |
13 changes: 13 additions & 0 deletions
13
packages/starlight-links-validator/tests/fixtures/relative-ignore/astro.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import starlight from '@astrojs/starlight' | ||
import { defineConfig } from 'astro/config' | ||
|
||
import starlightLinksValidator from '../..' | ||
|
||
export default defineConfig({ | ||
integrations: [ | ||
starlight({ | ||
plugins: [starlightLinksValidator({ errorOnRelativeLinks: false })], | ||
title: 'Starlight Links Validator Tests - relative ignore', | ||
}), | ||
], | ||
}) |
7 changes: 7 additions & 0 deletions
7
...nks-validator/tests/fixtures/relative-ignore/src/content/docs/guides/example.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: Example | ||
--- | ||
|
||
## Description | ||
|
||
This is an example page. |
9 changes: 9 additions & 0 deletions
9
...ght-links-validator/tests/fixtures/relative-ignore/src/content/docs/relative.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Relative | ||
--- | ||
|
||
- [Link to the same page](.) | ||
- [Link to the same page with its name](./relative) | ||
- [Link to another page in the same directory](./test) | ||
- [Link to another page in another directory](./guides/example) | ||
- [Link to another page in a parent directory](../test) |
19 changes: 19 additions & 0 deletions
19
...arlight-links-validator/tests/fixtures/relative-ignore/src/content/docs/test.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: Test | ||
--- | ||
|
||
# Some links | ||
|
||
- [External link](https://starlight.astro.build/) | ||
|
||
- [Example page](/guides/example) | ||
- [Example page](/guides/example/) | ||
|
||
- [Example page with hash](/guides/example#description) | ||
- [Example page with hash](/guides/example/#description) | ||
|
||
- [Unknown page](/unknown) | ||
- [Unknown page](/unknown/) | ||
|
||
- [Example page with unknown hash](/guides/example#unknown) | ||
- [Example page with unknown hash](/guides/example/#unknown) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { loadFixture } from './utils' | ||
|
||
test('should ignore relative links when the `errorOnRelativeLinks` option is set to `false`', async () => { | ||
expect.assertions(2) | ||
|
||
try { | ||
await loadFixture('relative-ignore') | ||
} catch (error) { | ||
expect(error).toMatch(/Found 4 invalid links in 1 file./) | ||
|
||
expect(error).toMatch( | ||
new RegExp(`▶ test/ | ||
├─ /unknown | ||
├─ /unknown/ | ||
├─ /guides/example#unknown | ||
└─ /guides/example/#unknown`), | ||
) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters