-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from HiDeoo/hd-feat-custom-ids
- Loading branch information
Showing
8 changed files
with
79 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
17 changes: 17 additions & 0 deletions
17
packages/starlight-links-validator/tests/custom-ids.test.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,17 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { ValidationErrorType } from '../libs/validation' | ||
|
||
import { expectValidationErrorCount, expectValidationErrors, loadFixture } from './utils' | ||
|
||
test('should validate links with custom IDs', async () => { | ||
expect.assertions(2) | ||
|
||
try { | ||
await loadFixture('custom-ids') | ||
} catch (error) { | ||
expectValidationErrorCount(error, 1, 1) | ||
|
||
expectValidationErrors(error, 'test/', [['#heading-with-custom-id', ValidationErrorType.InvalidAnchor]]) | ||
} | ||
}) |
17 changes: 17 additions & 0 deletions
17
packages/starlight-links-validator/tests/fixtures/custom-ids/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,17 @@ | ||
import starlight from '@astrojs/starlight' | ||
import { defineConfig } from 'astro/config' | ||
import remarkCustomHeadingId from 'remark-custom-heading-id' | ||
|
||
import starlightLinksValidator from '../..' | ||
|
||
export default defineConfig({ | ||
markdown: { | ||
remarkPlugins: [remarkCustomHeadingId], | ||
}, | ||
integrations: [ | ||
starlight({ | ||
plugins: [starlightLinksValidator()], | ||
title: 'Starlight Links Validator Tests - custom IDs', | ||
}), | ||
], | ||
}) |
12 changes: 12 additions & 0 deletions
12
...es/starlight-links-validator/tests/fixtures/custom-ids/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,12 @@ | ||
--- | ||
title: Test | ||
--- | ||
|
||
# Heading | ||
|
||
# Heading with custom ID {#custom-id} | ||
|
||
- [Link to heading with no custom ID](#heading) | ||
|
||
- [Link to heading with custom ID](#custom-id) | ||
- [Link to heading with custom ID using original ID](#heading-with-custom-id) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.