Skip to content

feat(v2): add support to import assets using relative link in markdown syntax - #3096

Merged
slorber merged 10 commits into
meta:masterfrom
MLH-Fellowship:anshul/transformAssets
Aug 3, 2020
Merged

slorber merged 10 commits into
meta:masterfrom
MLH-Fellowship:anshul/transformAssets

Conversation

@anshulrgoyal

@anshulrgoyal anshulrgoyal commented Jul 22, 2020 •

Copy link
Copy Markdown
Contributor

@anshulrgoyal
anshulrgoyal requested a review from yangshun as a code owner July 22, 2020 20:19
@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

docusaurus-bot commented Jul 22, 2020 •

Copy link
Copy Markdown
Contributor

@anshulrgoyal

Copy link
Copy Markdown
Contributor Author

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

@slorber slorber left a comment •

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@slorber

slorber commented Aug 3, 2020

Copy link
Copy Markdown
Collaborator

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 meta:master Aug 3, 2020
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
…n syntax (meta#3096)

* add a rehyper plugin

* fix yarn.lok

* add target

* convert to remark

* add docs

* remove unused package

* remove file-loader

* add test for file-loader

* fix test
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