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(content-docs): autogenerate category with linked doc metadata as fallback #6859

Merged
merged 2 commits into from
Mar 25, 2022

Conversation

Josh-Cena
Copy link
Collaborator

@Josh-Cena Josh-Cena commented Mar 6, 2022

Breaking change

The sidebar labels may have changed if you previously relied on a folder's name as category label. The index doc's title will be used instead. To restore the old behavior, simply add a label field in your _category_.json.

Motivation

Close #6254. Supercedes #6249

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Added a test case
In these pages: https://deploy-preview-6859--docusaurus-2.netlify.app/tests/docs/tests/category-links/custom-index-convention/intro/ the category labels are now the docs' titles instead of the folder names

@Josh-Cena Josh-Cena added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Mar 6, 2022
@Josh-Cena Josh-Cena requested review from slorber and lex111 as code owners March 6, 2022 11:42
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 6, 2022
@Josh-Cena Josh-Cena changed the title feat(content-docs): autogenerate category metadata fallback to linked doc metadata feat(content-docs): autogenerate category metadata with linked doc metadata as fallback Mar 6, 2022
@Josh-Cena Josh-Cena changed the title feat(content-docs): autogenerate category metadata with linked doc metadata as fallback feat(content-docs): autogenerate category with linked doc metadata as fallback Mar 6, 2022
return {
id,
position: doc.sidebarPosition,
label: doc.frontMatter.sidebar_label ?? doc.title,
Copy link
Collaborator Author

@Josh-Cena Josh-Cena Mar 6, 2022

Choose a reason for hiding this comment

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

Maybe it's too optimistic to fall back to doc.title? Maybe some users keep their folder names readable and they intend to use the folder name instead of the linked doc's title? But if a user doesn't want to use _category_.json, it is often convenient to make them not specify sidebar_label either...

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are options in case user is not happy, that looks good enough to me

@netlify
Copy link

netlify bot commented Mar 6, 2022

[V2]

Name Link
🔨 Latest commit 3478820
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/623dcd07c216ba00090aff8e
😎 Deploy Preview https://deploy-preview-6859--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 66
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

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

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

Size Change: 0 B

Total Size: 805 kB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 49.9 kB
website/build/assets/css/styles.********.css 105 kB
website/build/assets/js/main.********.js 612 kB
website/build/index.html 38.4 kB

compressed-size-action

@Josh-Cena Josh-Cena force-pushed the jc/autogenerate-category-metadata branch from afbf718 to 5b392a5 Compare March 25, 2022 13:54
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

@Josh-Cena Josh-Cena added the pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. label Mar 25, 2022
@Josh-Cena
Copy link
Collaborator Author

Going to mark this as a slight breaking change, because behavior has changed

@slorber slorber merged commit b5ceead into main Mar 25, 2022
@slorber slorber deleted the jc/autogenerate-category-metadata branch March 25, 2022 14:23
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: breaking change Existing sites may not build successfully in the new version. Description contains more details. pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autogenerated category with doc link: use doc frontmatter for category metadata
3 participants