Skip to content

Commit

Permalink
initial move
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Jul 19, 2024
1 parent 7544a23 commit 7f73e91
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 72 deletions.
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@docusaurus/logger": "3.4.0",
"@docusaurus/mdx-loader": "3.4.0",
"@docusaurus/module-type-aliases": "3.4.0",
"@docusaurus/theme-common": "3.4.0",
"@docusaurus/types": "3.4.0",
"@docusaurus/utils": "3.4.0",
"@docusaurus/utils-common": "3.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
useSidebarBreadcrumbs,
isVisibleSidebarItem,
} from '../docsUtils';
import {DocsSidebarProvider} from '../../contexts/docsSidebar';
import {DocsVersionProvider} from '../../contexts/docsVersion';
import {DocsSidebarProvider} from '../docsSidebar';
import {DocsVersionProvider} from '../docsVersion';
import type {
PropSidebar,
PropSidebarItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {useMemo, type ReactNode, useContext} from 'react';
import {ReactContextError} from '../utils/reactUtils';
import {ReactContextError} from '@docusaurus/theme-common/internal';
import type {PropDocContent} from '@docusaurus/plugin-content-docs';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {type ReactNode, useMemo, useState, useContext} from 'react';
import {ReactContextError} from '../utils/reactUtils';
import {ReactContextError} from '@docusaurus/theme-common/internal';

type ContextValue = {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import {
type GlobalVersion,
} from '@docusaurus/plugin-content-docs/client';
import {DEFAULT_PLUGIN_ID} from '@docusaurus/constants';
import {useThemeConfig, type ThemeConfig} from '@docusaurus/theme-common';
import {isDocsPluginEnabled} from './docsUtils';
import {
useThemeConfig,
type DocsVersionPersistence,
} from '../utils/useThemeConfig';
import {isDocsPluginEnabled} from '../utils/docsUtils';
import {ReactContextError} from '../utils/reactUtils';
import {createStorageSlot} from '../utils/storageUtils';
ReactContextError,
createStorageSlot,
} from '@docusaurus/theme-common/internal';

type DocsVersionPersistence = ThemeConfig['docs']['versionPersistence'];

const storageKey = (pluginId: string) => `docs-preferred-version-${pluginId}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {useMemo, useContext, type ReactNode} from 'react';
import {ReactContextError} from '../utils/reactUtils';
import {ReactContextError} from '@docusaurus/theme-common/internal';
import type {PropSidebar} from '@docusaurus/plugin-content-docs';

// Using a Symbol because null is a valid context value (a doc with no sidebar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ import {
type GlobalSidebar,
type GlobalDoc,
} from '@docusaurus/plugin-content-docs/client';
import {isSamePath} from '@docusaurus/theme-common/internal';
import type {Props as DocRootProps} from '@theme/DocRoot';
import {useDocsPreferredVersion} from '../contexts/docsPreferredVersion';
import {useDocsVersion} from '../contexts/docsVersion';
import {useDocsSidebar} from '../contexts/docsSidebar';
import {uniq} from './jsUtils';
import {isSamePath} from './routesUtils';
import {useDocsPreferredVersion} from './docsPreferredVersion';
import {useDocsVersion} from './docsVersion';
import {useDocsSidebar} from './docsSidebar';
import {uniq} from '@docusaurus/theme-common';

import type {
PropSidebar,
PropSidebarItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {type ReactNode, useContext} from 'react';
import {ReactContextError} from '../utils/reactUtils';
import {ReactContextError} from '@docusaurus/theme-common/internal';
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';

const Context = React.createContext<PropVersionMetadata | null>(null);
Expand Down
35 changes: 35 additions & 0 deletions packages/docusaurus-plugin-content-docs/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,41 @@ import {
} from './docsClientUtils';
import type {UseDataOptions} from '@docusaurus/types';

export {
isDocsPluginEnabled,
useDocById,
findSidebarCategory,
findFirstSidebarItemLink,
isActiveSidebarItem,
isVisibleSidebarItem,
useVisibleSidebarItems,
useSidebarBreadcrumbs,
useDocsVersionCandidates,
useLayoutDoc,
useLayoutDocsSidebar,
useDocRootMetadata,
useCurrentSidebarCategory,
filterDocCardListItems,
} from './docsUtils';

export {useDocsPreferredVersion} from './docsPreferredVersion';

export {
DocSidebarItemsExpandedStateProvider,
useDocSidebarItemsExpandedState,
} from './docSidebarItemsExpandedState';

export {DocsVersionProvider, useDocsVersion} from './docsVersion';

export {DocsSidebarProvider, useDocsSidebar} from './docsSidebar';

export {DocProvider, useDoc, type DocContextValue} from './doc';

export {
useDocsPreferredVersionByPluginId,
DocsPreferredVersionContextProvider,
} from './docsPreferredVersion';

export type ActivePlugin = {
pluginId: string;
pluginData: GlobalPluginData;
Expand Down
3 changes: 0 additions & 3 deletions packages/docusaurus-theme-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
"dependencies": {
"@docusaurus/mdx-loader": "3.4.0",
"@docusaurus/module-type-aliases": "3.4.0",
"@docusaurus/plugin-content-blog": "3.4.0",
"@docusaurus/plugin-content-docs": "3.4.0",
"@docusaurus/plugin-content-pages": "3.4.0",
"@docusaurus/utils": "3.4.0",
"@docusaurus/utils-common": "3.4.0",
"@types/history": "^4.7.11",
Expand Down
12 changes: 0 additions & 12 deletions packages/docusaurus-theme-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ export {

export {useContextualSearchFilters} from './utils/searchUtils';

export {
useCurrentSidebarCategory,
filterDocCardListItems,
} from './utils/docsUtils';

export {
useBlogListPageStructuredData,
useBlogPostStructuredData,
} from './utils/structuredDataUtils';

export {usePluralForm} from './utils/usePluralForm';

export {useCollapsible, Collapsible} from './components/Collapsible';
Expand Down Expand Up @@ -94,8 +84,6 @@ export {duplicates, uniq, groupBy} from './utils/jsUtils';

export {usePrismTheme} from './hooks/usePrismTheme';

export {useDocsPreferredVersion} from './contexts/docsPreferredVersion';

export {processAdmonitionProps} from './utils/admonitionUtils';

export {
Expand Down
39 changes: 0 additions & 39 deletions packages/docusaurus-theme-common/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,6 @@
// eslint-disable-next-line no-restricted-syntax
export * from './index';

export {
DocSidebarItemsExpandedStateProvider,
useDocSidebarItemsExpandedState,
} from './contexts/docSidebarItemsExpandedState';
export {DocsVersionProvider, useDocsVersion} from './contexts/docsVersion';
export {DocsSidebarProvider, useDocsSidebar} from './contexts/docsSidebar';

export {DocProvider, useDoc, type DocContextValue} from './contexts/doc';
export {
BlogPostProvider,
useBlogPost,
type BlogPostContextValue,
} from './contexts/blogPost';

export {
useDocsPreferredVersionByPluginId,
DocsPreferredVersionContextProvider,
} from './contexts/docsPreferredVersion';

export {
AnnouncementBarProvider,
useAnnouncementBar,
Expand All @@ -61,21 +42,6 @@ export {

export {docVersionSearchTag, DEFAULT_SEARCH_TAG} from './utils/searchUtils';

export {
isDocsPluginEnabled,
useDocById,
findSidebarCategory,
findFirstSidebarItemLink,
isActiveSidebarItem,
isVisibleSidebarItem,
useVisibleSidebarItems,
useSidebarBreadcrumbs,
useDocsVersionCandidates,
useLayoutDoc,
useLayoutDocsSidebar,
useDocRootMetadata,
} from './utils/docsUtils';

export {useTitleFormatter} from './utils/generalUtils';

export {useLocationChange} from './utils/useLocationChange';
Expand Down Expand Up @@ -113,11 +79,6 @@ export {
type TOCHighlightConfig,
} from './hooks/useTOCHighlight';

export {
useVisibleBlogSidebarItems,
groupBlogSidebarItemsByYear,
BlogSidebarItemList,
} from './utils/blogUtils';
export {useDateTimeFormat} from './utils/IntlUtils';

export {useHideableNavbar} from './hooks/useHideableNavbar';
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-common/src/utils/searchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useActivePluginAndVersion,
} from '@docusaurus/plugin-content-docs/client';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import {useDocsPreferredVersionByPluginId} from '../contexts/docsPreferredVersion';
import {useDocsPreferredVersionByPluginId} from '@docusaurus/plugin-content-docs/src/client/docsPreferredVersion';

export const DEFAULT_SEARCH_TAG = 'default';

Expand Down

0 comments on commit 7f73e91

Please sign in to comment.