Skip to content
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

Merged
merged 10 commits into from
Aug 3, 2020

Conversation

anshulrgoyal
Copy link
Contributor

@anshulrgoyal anshulrgoyal commented Jul 22, 2020

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

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 22, 2020
@anshulrgoyal anshulrgoyal changed the title add a rehyper plugin feat(v2): add support to import assets using relative link in markdown syntax Jul 22, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jul 22, 2020

Deploy preview for docusaurus-2 ready!

Built with commit 831c08e

https://deploy-preview-3096--docusaurus-2.netlify.app

@anshulrgoyal
Copy link
Contributor Author

I converted pr to use remark plugin since it will be more uniform.

Copy link
Collaborator

@slorber slorber left a 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}` : ''
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@slorber
Copy link
Collaborator

slorber commented Aug 3, 2020

LGTM :)

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Aug 3, 2020
@slorber slorber merged commit 3255599 into facebook:master Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants