Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation error when using the starlight-heading-badges plugin #73

Closed
andrii-bodnar opened this issue Nov 30, 2024 · 2 comments
Closed

Comments

@andrii-bodnar
Copy link

andrii-bodnar commented Nov 30, 2024

Describe the bug

When using the starlight-heading-badges plugin and referencing the heading with a badge from elsewhere in docs, the starlight-links-validator plugin fails with a validation error.

To Reproduce

  1. Setup the starlight-heading-badges plugin and create a heading with a badge: ## Hello :badge[New].
  2. Reference the heading in the current document or another page. For example, [click](#hello) or [click](/guides/example/#hello).
  3. Run the build to see the error:
 validating links 
11:59:41 [ERROR] ✗ Found 1 invalid link in 1 file.
11:59:41 ▶ /
11:59:41   └─ /guides/example/#hello - invalid hash

[AstroUserError] Links validation failed.

I also tried ## Hello:badge[New] (without the space), but the result is the same.

Expected behavior

No validation error.

How often does this bug happen?

Every time

System Info

No response

Additional Context

Minimal reproducible example (Stackblitz)

@andrii-bodnar
Copy link
Author

I guess it could be related to the same problem described in the #72 PR.

@andrii-bodnar andrii-bodnar changed the title Validation error when using the starlight-heading-badges plugin Validation error when using the starlight-heading-badges plugin Nov 30, 2024
@HiDeoo
Copy link
Owner

HiDeoo commented Dec 2, 2024

Thanks for the report 🙌

I initially thought like you that could be related to #72 but turns out I was wrong. Both plugins internally use remark plugins and the starlight-heading-badges one does some changes on the heading IDs that cannot be picked up by the starlight-links-validator one if it's not executed after the first one.

In this case, changing the order of the plugins in the Astro config should fix the issue:

-plugins: [starlightLinksValidator(), starlightHeadingBadges()],
+plugins: [starlightHeadingBadges(), starlightLinksValidator()],

@HiDeoo HiDeoo closed this as completed Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants