mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 12:22:45 +02:00
fix(plugin-docs,theme): refactor docs plugin routes and component tree (#7966)
This commit is contained in:
parent
c29218ea1d
commit
3b9b497d13
35 changed files with 1189 additions and 857 deletions
|
@ -73,7 +73,7 @@ export {
|
|||
useDocsVersionCandidates,
|
||||
useLayoutDoc,
|
||||
useLayoutDocsSidebar,
|
||||
useDocRouteMetadata,
|
||||
useDocRootMetadata,
|
||||
} from './utils/docsUtils';
|
||||
|
||||
export {useTitleFormatter} from './utils/generalUtils';
|
||||
|
|
|
@ -27,6 +27,9 @@ export const ThemeClassNames = {
|
|||
},
|
||||
wrapper: {
|
||||
main: 'main-wrapper',
|
||||
// TODO these wrapper class names are now quite useless
|
||||
// TODO do breaking change later in 3.0
|
||||
// we already add plugin name/id class on <html>: that's enough
|
||||
blogPages: 'blog-wrapper',
|
||||
docsPages: 'docs-wrapper',
|
||||
mdxPages: 'mdx-wrapper',
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
type GlobalSidebar,
|
||||
type GlobalDoc,
|
||||
} from '@docusaurus/plugin-content-docs/client';
|
||||
import type {Props as DocPageProps} from '@theme/DocPage';
|
||||
import type {Props as DocRootProps} from '@theme/DocRoot';
|
||||
import {useDocsPreferredVersion} from '../contexts/docsPreferredVersion';
|
||||
import {useDocsVersion} from '../contexts/docsVersion';
|
||||
import {useDocsSidebar} from '../contexts/docsSidebar';
|
||||
|
@ -290,14 +290,11 @@ Available doc ids are:
|
|||
* version metadata, and the subroutes creating individual doc pages. This hook
|
||||
* will match the current location against all known sub-routes.
|
||||
*
|
||||
* @param props The props received by `@theme/DocPage`
|
||||
* @param props The props received by `@theme/DocRoot`
|
||||
* @returns The data of the relevant document at the current location, or `null`
|
||||
* if no document associated with the current location can be found.
|
||||
*/
|
||||
export function useDocRouteMetadata({
|
||||
route,
|
||||
versionMetadata,
|
||||
}: DocPageProps): null | {
|
||||
export function useDocRootMetadata({route}: DocRootProps): null | {
|
||||
/** The element that should be rendered at the current location. */
|
||||
docElement: JSX.Element;
|
||||
/**
|
||||
|
@ -309,6 +306,7 @@ export function useDocRouteMetadata({
|
|||
sidebarItems: PropSidebar | undefined;
|
||||
} {
|
||||
const location = useLocation();
|
||||
const versionMetadata = useDocsVersion();
|
||||
const docRoutes = route.routes!;
|
||||
const currentDocRoute = docRoutes.find((docRoute) =>
|
||||
matchPath(location.pathname, docRoute),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue