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
onBrokenAnchors reports named anchor tags as broken links #9808
Comments
We'll try to improve this, but this is currently the intended behavior, because all anchors must be "collected" for the broken link checker to see them. CF-related issue: #9763 (comment) The current suggested workaround (requiring v3.1.1) is: import Link from '@docusaurus/Link';
<Link id="my-anchor"/> Please note that I'm keeping this open for now, as there's an opportunity for us to improve the DX. But please share more details about your use case. For now, it's hard to know if you created that JSX inside a React file or an MDX file, and that matters to me to design an improved solution, for which the technical solution could be radically different (remark plugin VS custom JSX pragma). Reading the repro steps, I kind of understand that the anchor is in an MDX doc file right? |
Yes exactly, my immediate use is to be able to have arbitrary (non-heading) anchors in MDX files. I haven't needed to use them in React pages. I would love for If |
We'll try to add support for However it's not possible to add support for
We validate each link anchor against all the anchors we successfully extracted from the target page, so it's important to collect all of them. For a given page, we either validate or not, but there's no middle ground. What you ask for basically means disabling the broken anchor check |
That would be great!
I understand. That's not what I want. I would much rather the arbitrary anchors get checked along with the heading anchors. It's just that right now, I really appreciate your taking the time to consider this, BTW. |
Is there some way to suppress this warning, this is currently blocking us from upgrading |
@nijikokun a warning does not prevent your site from building, and yes this is configurable as explained in the docs and release notes:
Disabling it is not a big deal, it just reverts to what we had in v3.0- But it would be better to fix the broken anchors and help us figure out when we report false positives (if it's a different case from the one above) |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
When you use named anchors (E.g.,
<a name="anchor">Some Text</a>
or self-closing ) in a doc page,onBrokenAnchors
reports it as a broken link.Reproducible demo
No response
Steps to reproduce
docusaurus.config.js
, setonBrokenAnchors
toWarn
(if not using the default setting).<a name="anchor">Some Text</a>
[Link Text](#anchor)
yarn build
).Expected behavior
No console feedback.
onBrokenAnchors
ignores the arbitrary named anchor because it's only supposed to work for anchors declared with theHeading
component.Actual behavior
onBrokenAnchors
reports the named anchor as a broken anchor. Example:Note that on the rendered page, the anchor works.
Your environment
Self-service
The text was updated successfully, but these errors were encountered: