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

Redocusaurus should collect heading ids / anchors #321

Open
slorber opened this issue Jan 8, 2024 · 2 comments
Open

Redocusaurus should collect heading ids / anchors #321

slorber opened this issue Jan 8, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@slorber
Copy link

slorber commented Jan 8, 2024

Hi

With Docusaurus v3.1 we introduced a broken anchors checker:

https://docusaurus.io/blog/releases/3.1#broken-anchors-checker

https://docusaurus.io/docs/docusaurus-core#useBrokenLinks

This requires collecting anchors for headings you create, otherwise Docusaurus doesn't know about those created anchors.

CleanShot 2024-01-08 at 15 43 17@2x

Note this api exists in Docusaurus 3.1 but not in 3.0 so you probably want to release a new major version requiring Docusaurus 3.1 to support this.


See also a Docusaurus user that gets reported Redocusaurus anchors links as broken:

facebook/docusaurus#6810 (comment)

@rohit-gohri
Copy link
Owner

Thanks @slorber for forwarding the issue! I'll try to look into what API redoc makes available to get the anchor ids but since the rendering is done mostly by redoc and not by this plugin it's possible that this is unfixable. Will try still

@slorber
Copy link
Author

slorber commented Jan 9, 2024

I understand.

Isn't there a way to know the heading its ahead of time by using AppStore or the spec file?

You don't have to call collectAnchor(anchor) in a heading component, you can do this at any level.

const {collectAnchor} = useBrokenLinks();
const anchors = getAnchorsFromSpec(spec);
anchors.forEach(collectAnchor);

The question is: can getAnchorsFromSpec(spec) be implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants