Refactor(server): share logic between server.js & generate.js #856
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Mostly refactoring into reusable functions and add small test for it
Refactor duplicate/ similar logic in
server.js
andgenerate.js
andreadMetadata.js
togetMetadata
inblog.js
https://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/generate.js#L156-L164
https://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/server.js#L255-L267
https://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/readMetadata.js#L326-L335
Refactor duplicate in
server.js
andgenerate.js
togetPages
inblog.js
https://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/server.js#L202-L224
https://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/generate.js#L180-L193
Refactor duplicate path replacement to a function in
blog.js
such ashttps://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/readMetadata.js#L320-L325
https://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/generate.js#L150-L155
Simplify docs redirectStr generation to function
getRedirectStr
in docs.jshttps://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/generate.js#L95-L109
Refactor duplicate in
server.js
andgenerate.js
on blogPost generationhttps://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/generate.js#L166-L175
https://github.com/facebook/Docusaurus/blob/9f718a5097dfa7f549690a711fb151ea82a335a8/lib/server/server.js#L269-L281
Add test for several key functions in new
blog.js
Remove redundant comments & some nits
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Links still work as per normal
https://deploy-preview-856--docusaurus-preview.netlify.com/
Related PRs
#847
#854