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
Documentation should also teach registering anchors in plugin code #9986
Comments
Hi! You cannot use |
Cause: Cannot find module '@docusaurus/useBrokenLinks'
Appreciate your confirmation @Josh-Cena - I figured as much after continuing my efforts.
If this is possible can you please point me at anything (docs/source examples/whatever) that would shine some light on how I do that? Exactly what I'm after. |
I somewhat suspect that it's impossible, since right now only the rendering code reports back valid anchors. I'll let @slorber answer though; if it's really not achievable, maybe we should have an API. It sounds useful for plugins that create external HTML pages that don't use Docusaurus themes. |
I suspect that as well.
Yeah that is my exact use case. Was trying to work around rohit-gohri/redocusaurus#321. The problem for me is that:
Just to see if it was possible, I tried to: generate the anchors in the plugin, stick them in global data, and then access them from a theme component so that I could
Regardless of the order of operations problem, it feels wrong to me to serialize and pump that data around in that manner. Seems like allowing for that in plugins like you say would be very nice for this use case. |
@danielspofford it would greatly help me if you provided a minimal repro that reports broken anchors that you would like to solve. This way, I could see how to fix that repro so that those anchors do not get reported anymore. Your repro just shows an attempt to import a React hook in Node.js code, something that is illegal). I can't act on it, and fix the problem, because the problem is not showcased in the first place. Show me the problem and I'll help fix it. Seeing a runnable sandbox of your setup that actually reports wrong broken anchors is more helpful than explaining things in text form. |
@slorber here is a minimal repro that reports broken anchors that I would like to solve. |
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
In any case: is it possible to useBrokenLinks in a plugin? If yes, how/what am I doing wrong? If no, is it possible to solve my problem with a plugin (inform docusaurus of routes that are valid so that it doesn't warn/throw on them with onBrokenLinks/onBrokenAnchors).
Reproducible demo
https://codesandbox.io/p/devbox/jovial-benji-f4599g
Steps to reproduce
src/plugins/foo/index.js
.plugins: ['src/plugins/foo']
to docusuarus config.If using the codesandbox link I provide - the above steps are already done (and are the only changes to the sandbox). The project as-is in there will fail to build.
Expected behavior
I hoped to use useBrokenLinks in a plugin to inform docusaurus about anchors/links that it should consider valid to stop receiving false onBrokenLinks/onBrokenAnchors warnings.
Actual behavior
Docusaurus fails to build - it cannot resolve the import of useBrokenLinks in a plugin.
Long form: https://gist.github.com/danielspofford/17993f7c77319d3639d52a8fd9f28fc3.
Your environment
Self-service
The text was updated successfully, but these errors were encountered: