-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
feat(v2): add support to import assets using relative link in markdown syntax #3096
feat(v2): add support to import assets using relative link in markdown syntax #3096
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 831c08e |
I converted pr to use remark plugin since it will be more uniform. |
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.
LGTM
Let regular file-loader of webpack kick in for regular files, not using the inline syntax
In particular, we want files processed by this feature to end up in /build/assets/files/file-hash.ext
It is important because we want in the future to enable users to cache the /build/assets folder aggressively (#3156)
|
||
node.type = 'jsx'; | ||
node.value = `<a target="_blank" ${ | ||
assetPath ? `href={require('!file-loader!${assetPath}').default}` : '' |
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.
We only need this "file-loader" because of the conflict with ideal-image, it is less likely to happen for other files.
When using this syntax, the options must be passed as querystring.
I think we should remove the !file-loader! so that default webpack file loader that we set kick in, so that correct options are applied automatically.
See also what I did here for images: #3180
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.
I added file-loader for unknow files.
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.
Probably user can add !file-loader!
in front of path themself :)
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.
Fixed
LGTM :) |
Motivation
Help in importing assets.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
By adding test
Here working example -> https://deploy-preview-3096--docusaurus-2.netlify.app/build/docs/next/markdown-features#common-assets