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(content-docs): refactor sidebars, Joi validation, generator rework, expose config types #5678

Merged
merged 17 commits into from
Oct 14, 2021

Conversation

Josh-Cena
Copy link
Collaborator

@Josh-Cena Josh-Cena commented Oct 10, 2021

Motivation

Followup of #5642 (comment). Hope this would make further work on sidebars easier.

Loading a sidebar follows the validation -> normalization -> processor workflow, and the type goes from SidebarsConfig -> NormalizedSidebars -> Sidebars.

A few types are renamed, and the config types are exposed to allow type-checking. Not sure if that would be BC

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Passes all unit tests + website build

@netlify
Copy link

netlify bot commented Oct 10, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: 04a8f6a

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/616645ed59ce8200073037bb

😎 Browse the preview: https://deploy-preview-5678--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Oct 10, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 90
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5678--docusaurus-2.netlify.app/

@Josh-Cena Josh-Cena marked this pull request as draft October 10, 2021 06:36
@Josh-Cena Josh-Cena marked this pull request as ready for review October 11, 2021 07:12
@Josh-Cena Josh-Cena changed the title refactor(content-docs): refactor sidebars logic + use Joi for validation refactor(content-docs): refactor sidebars, Joi validation, generator rework, expose config types Oct 11, 2021
@slorber slorber added the pr: maintenance This PR does not produce any behavior differences to end users when upgrading. label Oct 12, 2021
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 13, 2021
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 👍 thanks for the cleanup

Not easy to review since many files have no diff 🤪 but overall the behavior looks similar

module.exports = {
// @ts-check

/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice idea :)

}
return item;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are category child items still processed? It seems not and we probably lack a test here

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh I see it's using the recursive transformSidebarItems, looks fine

@@ -116,11 +117,9 @@ export default function pluginContentDocs(
getPathsToWatch() {
function getVersionPathsToWatch(version: VersionMetadata): string[] {
const result = [
...flatten(
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 in Node I think it's safe to use flatMap/flat now (wasn't the case before but we can refactor and remove usage of lodash everywhere)

@slorber slorber merged commit 8d92e9b into facebook:main Oct 14, 2021
@Josh-Cena Josh-Cena deleted the refactor-sidebars branch October 14, 2021 12:55
@Josh-Cena
Copy link
Collaborator Author

Yeah, after the code splitting I think we have a lot more places to add tests on, but I'm not good at writing unit tests, so let's leave it till we implement the next feature

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.

None yet

3 participants