mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-14 01:27:35 +02:00
refactor: new @docusaurus/plugin-content-docs/client interface (#6287)
This commit is contained in:
parent
3bc63b2b09
commit
024f2bf49b
20 changed files with 48 additions and 39 deletions
|
@ -11,7 +11,7 @@ import useGlobalData, {
|
|||
usePluginData,
|
||||
} from '@docusaurus/useGlobalData';
|
||||
|
||||
import type {GlobalPluginData, GlobalVersion} from '../../types';
|
||||
import type {GlobalPluginData, GlobalVersion} from '../types';
|
||||
import {
|
||||
getActivePlugin,
|
||||
getLatestVersion,
|
||||
|
@ -22,7 +22,7 @@ import {
|
|||
type ActiveDocContext,
|
||||
type DocVersionSuggestions,
|
||||
type GetActivePluginOptions,
|
||||
} from '../../client/docsClientUtils';
|
||||
} from './docsClientUtils';
|
||||
|
||||
// Important to use a constant object to avoid React useEffect executions etc...,
|
||||
// see https://github.com/facebook/docusaurus/issues/5089
|
||||
|
@ -37,6 +37,7 @@ export const useAllDocsData = (): Record<string, GlobalPluginData> =>
|
|||
export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
|
||||
usePluginData('docusaurus-plugin-content-docs', pluginId) as GlobalPluginData;
|
||||
|
||||
// TODO this feature should be provided by docusaurus core
|
||||
export const useActivePlugin = (
|
||||
options: GetActivePluginOptions = {},
|
||||
): ActivePlugin | undefined => {
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
export * from './globalDataHooks';
|
|
@ -79,14 +79,6 @@ export default async function pluginContentDocs(
|
|||
return {
|
||||
name: 'docusaurus-plugin-content-docs',
|
||||
|
||||
getThemePath() {
|
||||
return path.resolve(__dirname, './theme');
|
||||
},
|
||||
|
||||
getTypeScriptThemePath() {
|
||||
return path.resolve(__dirname, '..', 'src', 'theme');
|
||||
},
|
||||
|
||||
extendCli(cli) {
|
||||
const isDefaultPluginId = pluginId === DEFAULT_PLUGIN_ID;
|
||||
|
||||
|
|
|
@ -241,7 +241,8 @@ declare module '@theme/Seo' {
|
|||
export default Seo;
|
||||
}
|
||||
|
||||
declare module '@theme/hooks/useDocs' {
|
||||
// TODO can't we infer types directly from code?
|
||||
declare module '@docusaurus/plugin-content-docs/client' {
|
||||
type GlobalPluginData = import('./types').GlobalPluginData;
|
||||
type GlobalVersion = import('./types').GlobalVersion;
|
||||
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue