Repository navigation
feat(v2): global data + useGlobalData + docs versions dropdown - #2971
Conversation
|
Deploy preview for docusaurus-2 ready! Built with commit 525b0c2 |
This reverts commit f657b4c
# Conflicts: # packages/docusaurus-module-type-aliases/src/index.d.ts # packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.ts # packages/docusaurus-plugin-content-docs/src/index.ts # packages/docusaurus-theme-classic/src/theme/DocPage/index.tsx # packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx # packages/docusaurus-theme-classic/src/theme/Layout/index.tsx # packages/docusaurus-theme-classic/src/theme/Navbar/index.tsx
…+ try to fix remaining merge bugs
yangshun
left a comment
There was a problem hiding this comment.
I think global data is unavoidable. Gatsby's GraphQL schema is in fact global data which is queryable by every page.
Hence we need to introduce ways to make it more robust, possibly via namespacing. It'd be horrible if plugins overwrote each other's global data due to colliding keys.
I mentioned before that we want to allow multiple docs plugins in a website but the current versioning approach is global, which makes it impossible to do so. We should avoid the same mistake with global data.
yangshun
left a comment
There was a problem hiding this comment.
My only question is the renaming from links to items. Is it a necessary change? The helpful error message is super good though, so I'm not opposed to renaming.
| // TODO temporary (@alpha-58) | ||
| links: Joi.any().forbidden().messages({ | ||
| 'any.unknown': | ||
| 'themeConfig.navbar.links has been renamed as themeConfig.navbar.items', |
There was a problem hiding this comment.
Thanks 😊
The renaming is not required but I think items makes more sense than links, now that navbar items have custom types.
I imagine we'd have more navbar item types in the future, including custom ones provided by the user, and maybe the ability for plugins to provide some
|
thanks :) |
…2971) * doc components initial simplification * doc components initial simplification * add docContext test * Add poc of global data system + use it in the theme * Revert "doc components initial simplification" This reverts commit f657b4c * revert useless changes * avoid loosing context on docs switch * fix docs tests * fix @generated/globalData ts declaration / es import * typo * revert bad commit * refactor navbar in multiple parts + add navbar item types validation + try to fix remaining merge bugs * add missing watch mode for plugin debug * fix docs global data integration, move related hooks to docs plugin + convert to TS * change versions link label * fix activeClassName react warning * improve docs global data system + contextual navbar dropdown * fix bug preventing the deployment * refactor the global data system to namespace automatically by plugin name + plugin id * proper NavbarItem comp * fix tests * fix snapshot * extract theme config schema in separate file + rename navbar links to navbar items * minor typos * polish docs components/api * polish useDocs api surface * fix the docs version suggestions comp + data * refactors + add docsClientUtils unit tests * Add documentation * typo * Add check for duplicate plugin ids detection * multi-instance: createData plugin data should be namespaced by plugin instance id * remove attempt for multi-instance support
This PR implements the ability to switch from one doc version to the other, directly from the navbar, without loosing "context" (ie, the doc you are on):
To do this, some infra needed to be built:
docsVersionDropdowntype)Relevant docs:
useGlobalData,usePluginData,useAllPluginInstancesData)Breaking changes:
themeConfig.navbar.linksrenamed tothemeConfig.navbar.items(with custom error msg to help user)