-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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(theme-{classic,common}): refactor site/page/search metadata + apply className on html element #6925
Conversation
✔️ [V2] 🔨 Explore the source changes: 8d04740 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/6234c353bdb141000950bd71 😎 Browse the preview: https://deploy-preview-6925--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6925--docusaurus-2.netlify.app/ |
Size Change: +108 B (0%) Total Size: 804 kB
ℹ️ View Unchanged
|
# Conflicts: # packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx # packages/docusaurus-theme-classic/src/theme/DocPage/index.tsx # packages/docusaurus-theme-common/src/index.ts
👍 looks like it's working fine metadatas are good too, used an HTML diff tool to check a few pages |
Breaking change:
Some CSS classes were previously applied to the Layout wrapper. For maximum flexibility, they are now applied on the top-level HTML element, so your custom CSS selectors might have to be updated accordingly.
Why do we do this change? Because now you have the ability to target the site layout elements too (ie customize the navbar/sidebar/footer based on classes added to the top-level HTML element
The existing
.main-wrapper
class remains applied as before around Layout children prop:<div className="main-wrapper">{children}</div>
Example CSS selectors to update:
div.main-wrapper.blog-wrapper.blog-post-page { }
=>html.blog-wrapper.blog-post-page .main-wrapper {}
.main-wrapper.docs-wrapper { }
=>.docs-wrapper .main-wrapper {}
Note that
html.{docs,blog,pages}-wrapper
now looks like a weird className on the HTML element, so we'll likely remove this class later.Now each plugin routes already provide a top-level HTML className:
plugin-{docs,blog,pages}
,For example a md doc page now has this HTML element:
The most future-proof way to target the "inner" content of a docs-route is:
The most future-proof way to target the "inner" content of a doc page (rendering a md doc) is:
Motivation
Docusaurus core should apply some basic default metadata
It should be possible for a theme or site to provide global site metadata, overriding Docusaurus defaults
It should be possible for a page to override global site metadata, overriding global site metadata.
It should not be the responsibility of the Layout to apply page metadata.
Site metadata should be applied consistently even if the user decides to use a different layout.
Wrapper/page class names should be applied at the very top for maximum flexibility, see also #4280
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
Preview: metadata should be exactly as before (apart page classNames moved upper to the html element)