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

refactor(v2): move scripts/stylesheets injection to server side #2081

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Dec 3, 2019

Motivation

Move scripts/stylesheets siteConfig client side injection to server side using injectHtmlTag API

The benefit of this approach is that there won't be weird data-helmet attribute on the injected head tags and theoretically server side should be faster than react helmet.

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

Nothing broke
nothing broke

Add random scripts and stylesheets into config
still working

To consider

Deprecate scripts and stylesheets option ? But that would require v1 user migrating having to create a local plugin which can be slightly annoying

@endiliey endiliey requested a review from yangshun as a code owner December 3, 2019 12:52
@endiliey endiliey added the pr: maintenance This PR does not produce any behavior differences to end users when upgrading. label Dec 3, 2019
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 3, 2019
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit 8b9e473

https://deploy-preview-2081--docusaurus-2.netlify.com

@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit 8b9e473

https://deploy-preview-2081--docusaurus-preview.netlify.com

@wgao19
Copy link
Contributor

wgao19 commented Dec 4, 2019

sounded a bit peculiar to me at first but actually quite legit on a second thought, smart idea (╹◡╹)

@endiliey
Copy link
Contributor Author

endiliey commented Dec 4, 2019

because its a global tag and not page specific.

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

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

This is definitely an improvement. Great API there. Thanks :)

injectHtmlTags: () => {
const stylesheetsTags = stylesheets.map(source =>
typeof source === 'string'
? `<link rel="stylesheet" href="${source}">`
Copy link
Contributor

Choose a reason for hiding this comment

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

This API comes in handy now 😂

@yangshun yangshun merged commit 718b1e1 into master Dec 4, 2019
@yangshun yangshun deleted the endi/refactoragain branch December 4, 2019 05:40
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: maintenance This PR does not produce any behavior differences to end users when upgrading.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants