-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
fix(v2): markdown reference to file should not be page not found #2064
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 457e867 |
Deploy preview for docusaurus-preview ready! Built with commit 457e867 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be the disadvantages if this check move to the Link
component?
docusaurus/packages/docusaurus/src/client/exports/Link.js
Lines 70 to 72 in 6ff6656
return !targetLink || !isInternal ? ( | |
// eslint-disable-next-line jsx-a11y/anchor-has-content | |
<a {...props} href={targetLink} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be edge cases like where some bad user has a url like /docs/docusaurus.png in which its a valid internal URL (not a file), its still OK to use as it only causes page refresh.
How about we have a convention that and any path starting with "public" gets whitelisted from client-side navigations? Users can then put in their PDF files within website/static/public
.
Do we have all the possible routes on the client side? If we do we can know which paths are not part of the app and then fallback to full page navigation.
On a side note, the TOC for the Client API page is broken... I think it's treating the contents as a component to be rendered.
i feel parsing can be more evil than maintaining a known type of links that are supposed to be anchors |
More fine grain control. So note that this PR only changes the behavior of changing syntax in So that <a href="/some/url">Some link</a> or <Link to="/some/url">Some link</Link> So if we move it to
I feel that's gonna be more hard (to teach) and might cause lot of parsing problems. Like what if their baseUrl itself is
We do, but I see lot of problems for these. Like if we have 2000 routes, we gonna have to try and match if there's any matching URL, for every single Link. Another dynamic example is https://v2.docusaurus.io/feedback/p/support-for-markdown-to-do-list-feature
docusaurus/website/src/theme/NotFound.js Lines 12 to 15 in 34e942e
such that if its
Oh i guess its separate from this PR. Current v2 site also has it. Here's my recommendation:
Any other recommendation is appreciated Edit: We did it for v1 routing, but blacklisting docusaurus/packages/docusaurus-1.x/lib/server/routing.js Lines 16 to 18 in 2f9a368
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then 😄
Oh we are one such bad user https://v2.docusaurus.io/docs/docusaurus.config.js is not a file 😭😭😭😭 |
Yes, see the edit history of my comment 🤣. I wrote it without realizing you already considered it, then I removed it.
|
The good thing is that the page refresh is on markdown linking. using Link still works perfectly 🤣 |
Yeah! At first I was trying out the docs bottom navigation and was wondering why no full-page refresh lol |
Motivation
See https://v2.docusaurus.io/feedback/p/ability-to-download-static-assets-such-as-pdfs
In v1 it was possible to link to pdfs and other non-img static files in markdown using the syntax [file name] (/path/to/asset.pdf). When the user would click this link, the browser would trigger a download. In v2, docusaurus routing does not allow this and results in a 404, even though hitting my-site.com/path/to/asset.pdf directly will download the file just fine.
It's because we replace all
a
in MDX withLink
. But we should've checked if its a file first. 99.99% webpage url that links to file will have.xxx
notation in last part of URLThere might be edge cases like where some bad user has a url like
/docs/docusaurus.png
in which its a valid internal URL (not a file), its still OK to use as it only causes page refresh.Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
Before
After