diff --git a/packages/docusaurus-theme-common/src/internal.ts b/packages/docusaurus-theme-common/src/internal.ts index fa8979347891..89897f95a6b2 100644 --- a/packages/docusaurus-theme-common/src/internal.ts +++ b/packages/docusaurus-theme-common/src/internal.ts @@ -53,28 +53,16 @@ export { useTitleFormatter, } from './utils/titleFormatterUtils'; -export {useLocationChange} from './utils/useLocationChange'; - export {useLocalPathname} from './utils/useLocalPathname'; -export { - useHistoryPopHandler, - useHistorySelector, - useQueryStringValue, -} from './utils/historyUtils'; +export {useQueryStringValue} from './utils/historyUtils'; -export { - useFilteredAndTreeifiedTOC, - useTreeifiedTOC, - type TOCTreeNode, -} from './utils/tocUtils'; +export {useFilteredAndTreeifiedTOC, type TOCTreeNode} from './utils/tocUtils'; export { ScrollControllerProvider, - useScrollController, useScrollPosition, useScrollPositionBlocker, - useSmoothScrollTo, } from './utils/scrollUtils'; export {useHomePageRoute, isSamePath} from './utils/routesUtils'; diff --git a/packages/docusaurus-theme-common/src/utils/__tests__/__snapshots__/tocUtils.test.ts.snap b/packages/docusaurus-theme-common/src/utils/__tests__/__snapshots__/tocUtils.test.ts.snap deleted file mode 100644 index 786ba4892ad6..000000000000 --- a/packages/docusaurus-theme-common/src/utils/__tests__/__snapshots__/tocUtils.test.ts.snap +++ /dev/null @@ -1,40 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`useTreeifiedTOC > treeifies TOC without filtering 1`] = ` -[ - { - "children": [ - { - "children": [ - { - "children": [ - { - "children": [ - { - "children": [], - "id": "foxtrot", - "level": 6, - "value": "Foxtrot", - }, - ], - "id": "echo", - "level": 5, - "value": "Echo", - }, - ], - "id": "delta", - "level": 4, - "value": "Delta", - }, - ], - "id": "charlie", - "level": 3, - "value": "Charlie", - }, - ], - "id": "bravo", - "level": 2, - "value": "Bravo", - }, -] -`; diff --git a/packages/docusaurus-theme-common/src/utils/__tests__/tocUtils.test.ts b/packages/docusaurus-theme-common/src/utils/__tests__/tocUtils.test.ts index 11bc5f332277..e7217c6d6ac5 100644 --- a/packages/docusaurus-theme-common/src/utils/__tests__/tocUtils.test.ts +++ b/packages/docusaurus-theme-common/src/utils/__tests__/tocUtils.test.ts @@ -7,7 +7,7 @@ // @vitest-environment jsdom import {describe, expect, it} from 'vitest'; import {renderHook} from '@testing-library/react'; -import {useFilteredAndTreeifiedTOC, useTreeifiedTOC} from '../tocUtils'; +import {useFilteredAndTreeifiedTOC} from '../tocUtils'; import type {TOCItem} from '@docusaurus/mdx-loader'; const mockTOC: TOCItem[] = [ @@ -38,14 +38,6 @@ const mockTOC: TOCItem[] = [ }, ]; -describe('useTreeifiedTOC', () => { - it('treeifies TOC without filtering', () => { - expect( - renderHook(() => useTreeifiedTOC(mockTOC)).result.current, - ).toMatchSnapshot(); - }); -}); - describe('useFilteredAndTreeifiedTOC', () => { it('filters a toc with all heading levels', () => { expect( diff --git a/packages/docusaurus-theme-common/src/utils/scrollUtils.tsx b/packages/docusaurus-theme-common/src/utils/scrollUtils.tsx index 44a05d6221e8..c1a5fdd1eb76 100644 --- a/packages/docusaurus-theme-common/src/utils/scrollUtils.tsx +++ b/packages/docusaurus-theme-common/src/utils/scrollUtils.tsx @@ -64,7 +64,7 @@ export function ScrollControllerProvider({ * This API permits to temporarily disable/ignore scroll events. Motivated by * https://github.com/facebook/docusaurus/pull/5618 */ -export function useScrollController(): ScrollController { +function useScrollController(): ScrollController { const context = useContext(ScrollMonitorContext); if (context == null) { throw new ReactContextError('ScrollControllerProvider'); diff --git a/packages/docusaurus-theme-common/src/utils/tocUtils.ts b/packages/docusaurus-theme-common/src/utils/tocUtils.ts index 64be4cb51191..e23b25a805a3 100644 --- a/packages/docusaurus-theme-common/src/utils/tocUtils.ts +++ b/packages/docusaurus-theme-common/src/utils/tocUtils.ts @@ -52,14 +52,6 @@ function treeifyTOC(flatTOC: readonly TOCItem[]): TOCTreeNode[] { return rootNodes; } -/** - * Takes a flat TOC list (from the MDX loader) and treeifies it into what the - * TOC components expect. Memoized for performance. - */ -export function useTreeifiedTOC(toc: TOCItem[]): readonly TOCTreeNode[] { - return useMemo(() => treeifyTOC(toc), [toc]); -} - function filterTOC({ toc, minHeadingLevel, @@ -96,7 +88,7 @@ function filterTOC({ * TOC components expect, applying the `minHeadingLevel` and `maxHeadingLevel`. * Memoized for performance. * - * **Important**: this is not the same as `useTreeifiedTOC(toc.filter(...))`, + * **Important**: this is not the same as `treeifyTOC(toc.filter(...))`, * because we have to filter the TOC after it has been treeified. This is mostly * to ensure that weird TOC structures preserve their semantics. For example, an * h3-h2-h4 sequence should not be treeified as an "h3 > h4" hierarchy with