-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
asset links with trailing slash true can be broken #6282
Comments
This is actually not very easy to solve since we don't know what's a good heuristic for "assets" vs "pages"... I don't know if the static folder + Note that our documentation has the same usage as well and a trailing slash is appended in deploy preview (we have |
Yes, the problem can be seen here BTW: https://deploy-preview-6320--docusaurus-2.netlify.app/docs/markdown-features/assets/#files We can maybe add a new "hidden" prop in We already have some heuristic there: const hasAssetLikeExtension =
path.extname(assetPath) && !assetPath.match(/#|.md|.mdx|.html/); But this probably doesn't make sense to apply this generically in the Link component Using |
For people experiencing this issue, a workaround is to use absolute URL:s for the links. |
@stnor to avoid an absolute url, you should be able to put the file in |
I am sorry if that was unclear. I get the 404 with the url Are you suggesting it would work in markdown? edit: oh is I'll give it a go. |
Ok, got it. Nice that the Thanks. |
This changes the docusaurus config to avoid adding trailing slashes to routes. This is necessary only to be able to serve static files with no extension, due to a bug in docusaurus... facebook/docusaurus#6282
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
I have a hosting provider where trailing slash true is required, and that works great. However, for direct links to files, it is broken.
I have a file in the docs folder (which is also versioned), and a link in .md doc like so
However that link is transformed to
.../assets/file/haash.docx/
and that link ends up as a 404, as it's treated as path by host, rather than resolving the file.I think asset links should never get a trailing slash, but I don't have enough knowledge of other platforms to say that definitively.
Steps to reproduce
You can use the docusaurus docs to reproduce
On the /docs/markdown-features/assets#files page, attempt to open the .docx file links.
Expected behavior
It opens the linked file. File assets should probably never have trailing slashes, some hosts seem to be fine with it, but not all. I imagine all however a fine without for file assets.
Actual behavior
Document not found.
Your environment
Reproducible demo
No response
Self-service
The text was updated successfully, but these errors were encountered: