@docusaurus/theme-common 2.0.0-beta.17 → 2.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Collapsible/index.d.ts +32 -4
- package/lib/components/Collapsible/index.d.ts.map +1 -1
- package/lib/components/Collapsible/index.js +12 -3
- package/lib/components/Collapsible/index.js.map +1 -1
- package/lib/components/Details/index.d.ts +6 -1
- package/lib/components/Details/index.d.ts.map +1 -1
- package/lib/components/Details/index.js +8 -4
- package/lib/components/Details/index.js.map +1 -1
- package/lib/{utils/announcementBarUtils.d.ts → contexts/announcementBar.d.ts} +7 -3
- package/lib/contexts/announcementBar.d.ts.map +1 -0
- package/lib/{utils/announcementBarUtils.js → contexts/announcementBar.js} +11 -11
- package/lib/contexts/announcementBar.js.map +1 -0
- package/lib/{utils/colorModeUtils.d.ts → contexts/colorMode.d.ts} +12 -3
- package/lib/contexts/colorMode.d.ts.map +1 -0
- package/lib/contexts/colorMode.js +114 -0
- package/lib/contexts/colorMode.js.map +1 -0
- package/lib/contexts/docSidebarItemsExpandedState.d.ts +31 -0
- package/lib/contexts/docSidebarItemsExpandedState.d.ts.map +1 -0
- package/lib/{utils → contexts}/docSidebarItemsExpandedState.js +9 -4
- package/lib/contexts/docSidebarItemsExpandedState.js.map +1 -0
- package/lib/contexts/docsPreferredVersion.d.ts +28 -0
- package/lib/contexts/docsPreferredVersion.d.ts.map +1 -0
- package/lib/contexts/docsPreferredVersion.js +125 -0
- package/lib/contexts/docsPreferredVersion.js.map +1 -0
- package/lib/contexts/docsSidebar.d.ts +20 -0
- package/lib/contexts/docsSidebar.d.ts.map +1 -0
- package/lib/contexts/docsSidebar.js +29 -0
- package/lib/contexts/docsSidebar.js.map +1 -0
- package/lib/contexts/docsVersion.d.ts +20 -0
- package/lib/contexts/docsVersion.d.ts.map +1 -0
- package/lib/contexts/docsVersion.js +26 -0
- package/lib/contexts/docsVersion.js.map +1 -0
- package/lib/contexts/navbarMobileSidebar.d.ts +31 -0
- package/lib/contexts/navbarMobileSidebar.d.ts.map +1 -0
- package/lib/contexts/navbarMobileSidebar.js +56 -0
- package/lib/contexts/navbarMobileSidebar.js.map +1 -0
- package/lib/contexts/navbarSecondaryMenu.d.ts +38 -0
- package/lib/contexts/navbarSecondaryMenu.d.ts.map +1 -0
- package/lib/contexts/navbarSecondaryMenu.js +93 -0
- package/lib/contexts/navbarSecondaryMenu.js.map +1 -0
- package/lib/{utils/tabGroupChoiceUtils.d.ts → contexts/tabGroupChoice.d.ts} +5 -3
- package/lib/contexts/tabGroupChoice.d.ts.map +1 -0
- package/lib/{utils/tabGroupChoiceUtils.js → contexts/tabGroupChoice.js} +14 -20
- package/lib/contexts/tabGroupChoice.js.map +1 -0
- package/lib/hooks/useHideableNavbar.d.ts +7 -3
- package/lib/hooks/useHideableNavbar.d.ts.map +1 -1
- package/lib/hooks/useHideableNavbar.js +8 -6
- package/lib/hooks/useHideableNavbar.js.map +1 -1
- package/lib/hooks/useKeyboardNavigation.d.ts +11 -1
- package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -1
- package/lib/hooks/useKeyboardNavigation.js +11 -3
- package/lib/hooks/useKeyboardNavigation.js.map +1 -1
- package/lib/hooks/useLockBodyScroll.d.ts +5 -1
- package/lib/hooks/useLockBodyScroll.d.ts.map +1 -1
- package/lib/hooks/useLockBodyScroll.js +5 -1
- package/lib/hooks/useLockBodyScroll.js.map +1 -1
- package/lib/hooks/usePrismTheme.d.ts +5 -1
- package/lib/hooks/usePrismTheme.d.ts.map +1 -1
- package/lib/hooks/usePrismTheme.js +8 -4
- package/lib/hooks/usePrismTheme.js.map +1 -1
- package/lib/hooks/useSearchPage.d.ts +15 -4
- package/lib/hooks/useSearchPage.d.ts.map +1 -1
- package/lib/hooks/useSearchPage.js +3 -2
- package/lib/hooks/useSearchPage.js.map +1 -1
- package/lib/hooks/useTOCHighlight.d.ts +25 -0
- package/lib/hooks/useTOCHighlight.d.ts.map +1 -0
- package/lib/{utils → hooks}/useTOCHighlight.js +13 -9
- package/lib/hooks/useTOCHighlight.js.map +1 -0
- package/lib/hooks/useWindowSize.d.ts +14 -1
- package/lib/hooks/useWindowSize.d.ts.map +1 -1
- package/lib/hooks/useWindowSize.js +14 -11
- package/lib/hooks/useWindowSize.js.map +1 -1
- package/lib/index.d.ts +26 -30
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +26 -24
- package/lib/index.js.map +1 -1
- package/lib/utils/ThemeClassNames.d.ts +7 -0
- package/lib/utils/ThemeClassNames.d.ts.map +1 -1
- package/lib/utils/ThemeClassNames.js +7 -4
- package/lib/utils/ThemeClassNames.js.map +1 -1
- package/lib/utils/codeBlockUtils.d.ts +25 -2
- package/lib/utils/codeBlockUtils.d.ts.map +1 -1
- package/lib/utils/codeBlockUtils.js +36 -35
- package/lib/utils/codeBlockUtils.js.map +1 -1
- package/lib/utils/docsUtils.d.ts +25 -18
- package/lib/utils/docsUtils.d.ts.map +1 -1
- package/lib/utils/docsUtils.js +38 -56
- package/lib/utils/docsUtils.js.map +1 -1
- package/lib/utils/footerUtils.d.ts +13 -0
- package/lib/utils/footerUtils.d.ts.map +1 -0
- package/lib/utils/footerUtils.js +14 -0
- package/lib/utils/footerUtils.js.map +1 -0
- package/lib/utils/generalUtils.d.ts +4 -1
- package/lib/utils/generalUtils.d.ts.map +1 -1
- package/lib/utils/generalUtils.js +6 -3
- package/lib/utils/generalUtils.js.map +1 -1
- package/lib/utils/historyUtils.d.ts +1 -7
- package/lib/utils/historyUtils.d.ts.map +1 -1
- package/lib/utils/historyUtils.js +10 -13
- package/lib/utils/historyUtils.js.map +1 -1
- package/lib/utils/jsUtils.d.ts +1 -1
- package/lib/utils/jsUtils.js +1 -1
- package/lib/utils/metadataUtils.d.ts +38 -0
- package/lib/utils/metadataUtils.d.ts.map +1 -0
- package/lib/utils/metadataUtils.js +61 -0
- package/lib/utils/metadataUtils.js.map +1 -0
- package/lib/utils/navbarUtils.d.ts +21 -0
- package/lib/utils/navbarUtils.d.ts.map +1 -0
- package/lib/utils/navbarUtils.js +30 -0
- package/lib/utils/navbarUtils.js.map +1 -0
- package/lib/utils/reactUtils.d.ts +16 -5
- package/lib/utils/reactUtils.d.ts.map +1 -1
- package/lib/utils/reactUtils.js +28 -7
- package/lib/utils/reactUtils.js.map +1 -1
- package/lib/utils/regexpUtils.d.ts +2 -1
- package/lib/utils/regexpUtils.d.ts.map +1 -1
- package/lib/utils/regexpUtils.js +2 -1
- package/lib/utils/regexpUtils.js.map +1 -1
- package/lib/utils/routesUtils.d.ts +14 -2
- package/lib/utils/routesUtils.d.ts.map +1 -1
- package/lib/utils/routesUtils.js +20 -7
- package/lib/utils/routesUtils.js.map +1 -1
- package/lib/utils/scrollUtils.d.ts +32 -26
- package/lib/utils/scrollUtils.d.ts.map +1 -1
- package/lib/utils/scrollUtils.js +30 -17
- package/lib/utils/scrollUtils.js.map +1 -1
- package/lib/utils/searchUtils.d.ts +12 -0
- package/lib/utils/searchUtils.d.ts.map +1 -1
- package/lib/utils/searchUtils.js +34 -0
- package/lib/utils/searchUtils.js.map +1 -1
- package/lib/utils/storageUtils.d.ts +10 -7
- package/lib/utils/storageUtils.d.ts.map +1 -1
- package/lib/utils/storageUtils.js +20 -12
- package/lib/utils/storageUtils.js.map +1 -1
- package/lib/utils/tagsUtils.d.ts +5 -2
- package/lib/utils/tagsUtils.d.ts.map +1 -1
- package/lib/utils/tagsUtils.js +7 -4
- package/lib/utils/tagsUtils.js.map +1 -1
- package/lib/utils/tocUtils.d.ts +16 -0
- package/lib/utils/tocUtils.d.ts.map +1 -1
- package/lib/utils/tocUtils.js +17 -6
- package/lib/utils/tocUtils.js.map +1 -1
- package/lib/utils/useAlternatePageUtils.d.ts +20 -1
- package/lib/utils/useAlternatePageUtils.d.ts.map +1 -1
- package/lib/utils/useAlternatePageUtils.js +6 -3
- package/lib/utils/useAlternatePageUtils.js.map +1 -1
- package/lib/utils/useLocalPathname.d.ts +5 -0
- package/lib/utils/useLocalPathname.d.ts.map +1 -1
- package/lib/utils/useLocalPathname.js +6 -4
- package/lib/utils/useLocalPathname.js.map +1 -1
- package/lib/utils/useLocationChange.d.ts +7 -5
- package/lib/utils/useLocationChange.d.ts.map +1 -1
- package/lib/utils/useLocationChange.js +6 -2
- package/lib/utils/useLocationChange.js.map +1 -1
- package/lib/utils/usePluralForm.d.ts +11 -0
- package/lib/utils/usePluralForm.d.ts.map +1 -1
- package/lib/utils/usePluralForm.js +19 -24
- package/lib/utils/usePluralForm.js.map +1 -1
- package/lib/utils/useThemeConfig.d.ts +21 -11
- package/lib/utils/useThemeConfig.d.ts.map +1 -1
- package/lib/utils/useThemeConfig.js +3 -0
- package/lib/utils/useThemeConfig.js.map +1 -1
- package/package.json +8 -9
- package/src/components/Collapsible/index.tsx +40 -22
- package/src/components/Details/index.tsx +11 -6
- package/src/{utils/announcementBarUtils.tsx → contexts/announcementBar.tsx} +17 -18
- package/src/contexts/colorMode.tsx +176 -0
- package/src/contexts/docSidebarItemsExpandedState.tsx +55 -0
- package/src/contexts/docsPreferredVersion.tsx +250 -0
- package/src/contexts/docsSidebar.tsx +42 -0
- package/src/contexts/docsVersion.tsx +36 -0
- package/src/contexts/navbarMobileSidebar.tsx +99 -0
- package/src/contexts/navbarSecondaryMenu.tsx +170 -0
- package/src/{utils/tabGroupChoiceUtils.tsx → contexts/tabGroupChoice.tsx} +21 -28
- package/src/hooks/useHideableNavbar.ts +11 -11
- package/src/hooks/useKeyboardNavigation.ts +11 -3
- package/src/hooks/useLockBodyScroll.ts +5 -2
- package/src/hooks/usePrismTheme.ts +8 -4
- package/src/hooks/useSearchPage.ts +18 -5
- package/src/{utils → hooks}/useTOCHighlight.ts +21 -12
- package/src/hooks/useWindowSize.ts +14 -12
- package/src/index.ts +68 -56
- package/src/utils/ThemeClassNames.ts +10 -6
- package/src/utils/codeBlockUtils.ts +49 -47
- package/src/utils/docsUtils.tsx +48 -99
- package/src/utils/footerUtils.ts +18 -0
- package/src/utils/generalUtils.ts +6 -3
- package/src/utils/historyUtils.ts +11 -17
- package/src/utils/jsUtils.ts +1 -1
- package/src/utils/metadataUtils.tsx +115 -0
- package/src/utils/navbarUtils.tsx +40 -0
- package/src/utils/reactUtils.tsx +31 -8
- package/src/utils/regexpUtils.ts +2 -1
- package/src/utils/routesUtils.ts +27 -8
- package/src/utils/scrollUtils.tsx +44 -45
- package/src/utils/searchUtils.ts +49 -0
- package/src/utils/storageUtils.ts +21 -13
- package/src/utils/tagsUtils.ts +14 -7
- package/src/utils/tocUtils.ts +18 -7
- package/src/utils/useAlternatePageUtils.ts +17 -5
- package/src/utils/useLocalPathname.ts +6 -4
- package/src/utils/useLocationChange.ts +12 -10
- package/src/utils/usePluralForm.ts +27 -24
- package/src/utils/useThemeConfig.ts +16 -11
- package/lib/utils/announcementBarUtils.d.ts.map +0 -1
- package/lib/utils/announcementBarUtils.js.map +0 -1
- package/lib/utils/colorModeUtils.d.ts.map +0 -1
- package/lib/utils/colorModeUtils.js +0 -107
- package/lib/utils/colorModeUtils.js.map +0 -1
- package/lib/utils/docSidebarItemsExpandedState.d.ts +0 -17
- package/lib/utils/docSidebarItemsExpandedState.d.ts.map +0 -1
- package/lib/utils/docSidebarItemsExpandedState.js.map +0 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +0 -22
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +0 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +0 -92
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +0 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +0 -14
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts.map +0 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +0 -19
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js.map +0 -1
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +0 -14
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts.map +0 -1
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +0 -41
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js.map +0 -1
- package/lib/utils/mobileSecondaryMenu.d.ts +0 -21
- package/lib/utils/mobileSecondaryMenu.d.ts.map +0 -1
- package/lib/utils/mobileSecondaryMenu.js +0 -51
- package/lib/utils/mobileSecondaryMenu.js.map +0 -1
- package/lib/utils/pathUtils.d.ts +0 -8
- package/lib/utils/pathUtils.d.ts.map +0 -1
- package/lib/utils/pathUtils.js +0 -14
- package/lib/utils/pathUtils.js.map +0 -1
- package/lib/utils/tabGroupChoiceUtils.d.ts.map +0 -1
- package/lib/utils/tabGroupChoiceUtils.js.map +0 -1
- package/lib/utils/useContextualSearchFilters.d.ts +0 -12
- package/lib/utils/useContextualSearchFilters.d.ts.map +0 -1
- package/lib/utils/useContextualSearchFilters.js +0 -36
- package/lib/utils/useContextualSearchFilters.js.map +0 -1
- package/lib/utils/usePrevious.d.ts +0 -8
- package/lib/utils/usePrevious.d.ts.map +0 -1
- package/lib/utils/usePrevious.js +0 -16
- package/lib/utils/usePrevious.js.map +0 -1
- package/lib/utils/useTOCHighlight.d.ts +0 -14
- package/lib/utils/useTOCHighlight.d.ts.map +0 -1
- package/lib/utils/useTOCHighlight.js.map +0 -1
- package/src/utils/colorModeUtils.tsx +0 -158
- package/src/utils/docSidebarItemsExpandedState.tsx +0 -40
- package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +0 -166
- package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +0 -33
- package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +0 -70
- package/src/utils/mobileSecondaryMenu.tsx +0 -114
- package/src/utils/pathUtils.ts +0 -19
- package/src/utils/useContextualSearchFilters.ts +0 -53
- package/src/utils/usePrevious.ts +0 -19
|
@@ -6,37 +6,23 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, {
|
|
9
|
-
createContext,
|
|
10
|
-
type ReactNode,
|
|
11
9
|
useCallback,
|
|
12
10
|
useContext,
|
|
13
11
|
useEffect,
|
|
14
12
|
useLayoutEffect,
|
|
15
13
|
useMemo,
|
|
16
14
|
useRef,
|
|
15
|
+
type ReactNode,
|
|
17
16
|
} from 'react';
|
|
18
17
|
import {useDynamicCallback, ReactContextError} from './reactUtils';
|
|
19
18
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
20
19
|
|
|
21
|
-
/**
|
|
22
|
-
* We need a way to update the scroll position while ignoring scroll events
|
|
23
|
-
* without affecting Navbar/BackToTop visibility
|
|
24
|
-
*
|
|
25
|
-
* This API permits to temporarily disable/ignore scroll events
|
|
26
|
-
* Motivated by https://github.com/facebook/docusaurus/pull/5618
|
|
27
|
-
*/
|
|
28
20
|
type ScrollController = {
|
|
29
|
-
/**
|
|
30
|
-
* A boolean ref tracking whether scroll events are enabled
|
|
31
|
-
*/
|
|
21
|
+
/** A boolean ref tracking whether scroll events are enabled. */
|
|
32
22
|
scrollEventsEnabledRef: React.MutableRefObject<boolean>;
|
|
33
|
-
/**
|
|
34
|
-
* Enables scroll events in `useScrollPosition`
|
|
35
|
-
*/
|
|
23
|
+
/** Enable scroll events in `useScrollPosition`. */
|
|
36
24
|
enableScrollEvents: () => void;
|
|
37
|
-
/**
|
|
38
|
-
* Disables scroll events in `useScrollPosition`
|
|
39
|
-
*/
|
|
25
|
+
/** Disable scroll events in `useScrollPosition`. */
|
|
40
26
|
disableScrollEvents: () => void;
|
|
41
27
|
};
|
|
42
28
|
|
|
@@ -57,7 +43,7 @@ function useScrollControllerContextValue(): ScrollController {
|
|
|
57
43
|
);
|
|
58
44
|
}
|
|
59
45
|
|
|
60
|
-
const ScrollMonitorContext = createContext<ScrollController | undefined>(
|
|
46
|
+
const ScrollMonitorContext = React.createContext<ScrollController | undefined>(
|
|
61
47
|
undefined,
|
|
62
48
|
);
|
|
63
49
|
|
|
@@ -66,13 +52,21 @@ export function ScrollControllerProvider({
|
|
|
66
52
|
}: {
|
|
67
53
|
children: ReactNode;
|
|
68
54
|
}): JSX.Element {
|
|
55
|
+
const value = useScrollControllerContextValue();
|
|
69
56
|
return (
|
|
70
|
-
<ScrollMonitorContext.Provider value={
|
|
57
|
+
<ScrollMonitorContext.Provider value={value}>
|
|
71
58
|
{children}
|
|
72
59
|
</ScrollMonitorContext.Provider>
|
|
73
60
|
);
|
|
74
61
|
}
|
|
75
62
|
|
|
63
|
+
/**
|
|
64
|
+
* We need a way to update the scroll position while ignoring scroll events
|
|
65
|
+
* so as not to toggle Navbar/BackToTop visibility.
|
|
66
|
+
*
|
|
67
|
+
* This API permits to temporarily disable/ignore scroll events. Motivated by
|
|
68
|
+
* https://github.com/facebook/docusaurus/pull/5618
|
|
69
|
+
*/
|
|
76
70
|
export function useScrollController(): ScrollController {
|
|
77
71
|
const context = useContext(ScrollMonitorContext);
|
|
78
72
|
if (context == null) {
|
|
@@ -81,6 +75,8 @@ export function useScrollController(): ScrollController {
|
|
|
81
75
|
return context;
|
|
82
76
|
}
|
|
83
77
|
|
|
78
|
+
type ScrollPosition = {scrollX: number; scrollY: number};
|
|
79
|
+
|
|
84
80
|
const getScrollPosition = (): ScrollPosition | null =>
|
|
85
81
|
ExecutionEnvironment.canUseDOM
|
|
86
82
|
? {
|
|
@@ -89,8 +85,14 @@ const getScrollPosition = (): ScrollPosition | null =>
|
|
|
89
85
|
}
|
|
90
86
|
: null;
|
|
91
87
|
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
/**
|
|
89
|
+
* This hook fires an effect when the scroll position changes. The effect will
|
|
90
|
+
* be provided with the before/after scroll positions. Note that the effect may
|
|
91
|
+
* not be always run: if scrolling is disabled through `useScrollController`, it
|
|
92
|
+
* will be a no-op.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link useScrollController}
|
|
95
|
+
*/
|
|
94
96
|
export function useScrollPosition(
|
|
95
97
|
effect: (
|
|
96
98
|
position: ScrollPosition,
|
|
@@ -125,22 +127,16 @@ export function useScrollPosition(
|
|
|
125
127
|
window.addEventListener('scroll', handleScroll, opts);
|
|
126
128
|
|
|
127
129
|
return () => window.removeEventListener('scroll', handleScroll, opts);
|
|
128
|
-
}, [
|
|
129
|
-
dynamicEffect,
|
|
130
|
-
scrollEventsEnabledRef,
|
|
131
130
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
132
|
-
|
|
133
|
-
]);
|
|
131
|
+
}, [dynamicEffect, scrollEventsEnabledRef, ...deps]);
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
type UseScrollPositionSaver = {
|
|
137
|
-
/**
|
|
138
|
-
* Measure the top of an element, and store the details
|
|
139
|
-
*/
|
|
135
|
+
/** Measure the top of an element, and store the details. */
|
|
140
136
|
save: (elem: HTMLElement) => void;
|
|
141
137
|
/**
|
|
142
138
|
* Restore the page position to keep the stored element's position from
|
|
143
|
-
* the top of the viewport, and remove the stored details
|
|
139
|
+
* the top of the viewport, and remove the stored details.
|
|
144
140
|
*/
|
|
145
141
|
restore: () => {restored: boolean};
|
|
146
142
|
};
|
|
@@ -178,21 +174,24 @@ function useScrollPositionSaver(): UseScrollPositionSaver {
|
|
|
178
174
|
return useMemo(() => ({save, restore}), [restore, save]);
|
|
179
175
|
}
|
|
180
176
|
|
|
181
|
-
type UseScrollPositionBlockerReturn = {
|
|
182
|
-
blockElementScrollPositionUntilNextRender: (el: HTMLElement) => void;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
177
|
/**
|
|
186
|
-
* This hook permits to "block" the scroll position of a
|
|
178
|
+
* This hook permits to "block" the scroll position of a DOM element.
|
|
187
179
|
* The idea is that we should be able to update DOM content above this element
|
|
188
|
-
* but the screen position of this element should not change
|
|
180
|
+
* but the screen position of this element should not change.
|
|
189
181
|
*
|
|
190
|
-
* Feature motivated by the Tabs groups:
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
182
|
+
* Feature motivated by the Tabs groups: clicking on a tab may affect tabs of
|
|
183
|
+
* the same group upper in the tree, yet to avoid a bad UX, the clicked tab must
|
|
184
|
+
* remain under the user mouse.
|
|
185
|
+
*
|
|
186
|
+
* @see https://github.com/facebook/docusaurus/pull/5618
|
|
194
187
|
*/
|
|
195
|
-
export function useScrollPositionBlocker():
|
|
188
|
+
export function useScrollPositionBlocker(): {
|
|
189
|
+
/**
|
|
190
|
+
* Takes an element, and keeps its screen position no matter what's getting
|
|
191
|
+
* rendered above it, until the next render.
|
|
192
|
+
*/
|
|
193
|
+
blockElementScrollPositionUntilNextRender: (el: HTMLElement) => void;
|
|
194
|
+
} {
|
|
196
195
|
const scrollController = useScrollController();
|
|
197
196
|
const scrollPositionSaver = useScrollPositionSaver();
|
|
198
197
|
|
|
@@ -208,9 +207,9 @@ export function useScrollPositionBlocker(): UseScrollPositionBlockerReturn {
|
|
|
208
207
|
const {restored} = scrollPositionSaver.restore();
|
|
209
208
|
nextLayoutEffectCallbackRef.current = undefined;
|
|
210
209
|
|
|
211
|
-
// Restoring the former scroll position will trigger a scroll event
|
|
212
|
-
//
|
|
213
|
-
//
|
|
210
|
+
// Restoring the former scroll position will trigger a scroll event. We
|
|
211
|
+
// need to wait for next scroll event to happen before enabling the
|
|
212
|
+
// scrollController events again.
|
|
214
213
|
if (restored) {
|
|
215
214
|
const handleScrollRestoreEvent = () => {
|
|
216
215
|
scrollController.enableScrollEvents();
|
package/src/utils/searchUtils.ts
CHANGED
|
@@ -5,11 +5,60 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import {
|
|
9
|
+
useAllDocsData,
|
|
10
|
+
useActivePluginAndVersion,
|
|
11
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
12
|
+
import {useDocsPreferredVersionByPluginId} from '../contexts/docsPreferredVersion';
|
|
13
|
+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
14
|
+
|
|
8
15
|
export const DEFAULT_SEARCH_TAG = 'default';
|
|
9
16
|
|
|
17
|
+
/** The search tag to append as each doc's metadata. */
|
|
10
18
|
export function docVersionSearchTag(
|
|
11
19
|
pluginId: string,
|
|
12
20
|
versionName: string,
|
|
13
21
|
): string {
|
|
14
22
|
return `docs-${pluginId}-${versionName}`;
|
|
15
23
|
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Gets the relevant context information for contextual search.
|
|
27
|
+
*
|
|
28
|
+
* The value is generic and not coupled to Algolia/DocSearch, since we may want
|
|
29
|
+
* to support multiple search engines, or allowing users to use their own search
|
|
30
|
+
* engine solution.
|
|
31
|
+
*/
|
|
32
|
+
export function useContextualSearchFilters(): {locale: string; tags: string[]} {
|
|
33
|
+
const {i18n} = useDocusaurusContext();
|
|
34
|
+
const allDocsData = useAllDocsData();
|
|
35
|
+
const activePluginAndVersion = useActivePluginAndVersion();
|
|
36
|
+
const docsPreferredVersionByPluginId = useDocsPreferredVersionByPluginId();
|
|
37
|
+
|
|
38
|
+
function getDocPluginTags(pluginId: string) {
|
|
39
|
+
const activeVersion =
|
|
40
|
+
activePluginAndVersion?.activePlugin?.pluginId === pluginId
|
|
41
|
+
? activePluginAndVersion.activeVersion
|
|
42
|
+
: undefined;
|
|
43
|
+
|
|
44
|
+
const preferredVersion = docsPreferredVersionByPluginId[pluginId];
|
|
45
|
+
|
|
46
|
+
const latestVersion = allDocsData[pluginId]!.versions.find(
|
|
47
|
+
(v) => v.isLast,
|
|
48
|
+
)!;
|
|
49
|
+
|
|
50
|
+
const version = activeVersion ?? preferredVersion ?? latestVersion;
|
|
51
|
+
|
|
52
|
+
return docVersionSearchTag(pluginId, version.name);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const tags = [
|
|
56
|
+
DEFAULT_SEARCH_TAG,
|
|
57
|
+
...Object.keys(allDocsData).map(getDocPluginTags),
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
locale: i18n.currentLocale,
|
|
62
|
+
tags,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -11,8 +11,12 @@ export type StorageType = typeof StorageTypes[number];
|
|
|
11
11
|
|
|
12
12
|
const DefaultStorageType: StorageType = 'localStorage';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Will return `null` if browser storage is unavailable (like running Docusaurus
|
|
16
|
+
* in an iframe). This should NOT be called in SSR.
|
|
17
|
+
*
|
|
18
|
+
* @see https://github.com/facebook/docusaurus/pull/4501
|
|
19
|
+
*/
|
|
16
20
|
function getBrowserStorage(
|
|
17
21
|
storageType: StorageType = DefaultStorageType,
|
|
18
22
|
): Storage | null {
|
|
@@ -32,11 +36,12 @@ function getBrowserStorage(
|
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
39
|
+
let hasLoggedBrowserStorageNotAvailableWarning = false;
|
|
35
40
|
/**
|
|
36
|
-
* Poor man's memoization to avoid logging multiple times the same warning
|
|
37
|
-
* Sometimes, localStorage
|
|
41
|
+
* Poor man's memoization to avoid logging multiple times the same warning.
|
|
42
|
+
* Sometimes, `localStorage`/`sessionStorage` is unavailable due to browser
|
|
43
|
+
* policies.
|
|
38
44
|
*/
|
|
39
|
-
let hasLoggedBrowserStorageNotAvailableWarning = false;
|
|
40
45
|
function logOnceBrowserStorageNotAvailableWarning(error: Error) {
|
|
41
46
|
if (!hasLoggedBrowserStorageNotAvailableWarning) {
|
|
42
47
|
console.warn(
|
|
@@ -61,7 +66,7 @@ const NoopStorageSlot: StorageSlot = {
|
|
|
61
66
|
del: () => {},
|
|
62
67
|
};
|
|
63
68
|
|
|
64
|
-
//
|
|
69
|
+
// Fail-fast, as storage APIs should not be used during the SSR process
|
|
65
70
|
function createServerStorageSlot(key: string): StorageSlot {
|
|
66
71
|
function throwError(): never {
|
|
67
72
|
throw new Error(`Illegal storage API usage for storage key "${key}".
|
|
@@ -77,16 +82,19 @@ Please only call storage APIs in effects and event handlers.`);
|
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
/**
|
|
80
|
-
* Creates an
|
|
81
|
-
*
|
|
85
|
+
* Creates an interface to work on a particular key in the storage model.
|
|
86
|
+
* Note that this function only initializes the interface, but doesn't allocate
|
|
87
|
+
* anything by itself (i.e. no side-effects).
|
|
88
|
+
*
|
|
89
|
+
* The API is fail-safe, since usage of browser storage should be considered
|
|
82
90
|
* unreliable. Local storage might simply be unavailable (iframe + browser
|
|
83
91
|
* security) or operations might fail individually. Please assume that using
|
|
84
|
-
* this API can be a
|
|
92
|
+
* this API can be a no-op. See also https://github.com/facebook/docusaurus/issues/6036
|
|
85
93
|
*/
|
|
86
|
-
export
|
|
94
|
+
export function createStorageSlot(
|
|
87
95
|
key: string,
|
|
88
96
|
options?: {persistence?: StorageType},
|
|
89
|
-
): StorageSlot
|
|
97
|
+
): StorageSlot {
|
|
90
98
|
if (typeof window === 'undefined') {
|
|
91
99
|
return createServerStorageSlot(key);
|
|
92
100
|
}
|
|
@@ -121,10 +129,10 @@ export const createStorageSlot = (
|
|
|
121
129
|
}
|
|
122
130
|
},
|
|
123
131
|
};
|
|
124
|
-
}
|
|
132
|
+
}
|
|
125
133
|
|
|
126
134
|
/**
|
|
127
|
-
* Returns a list of all the keys currently stored in browser storage
|
|
135
|
+
* Returns a list of all the keys currently stored in browser storage,
|
|
128
136
|
* or an empty list if browser storage can't be accessed.
|
|
129
137
|
*/
|
|
130
138
|
export function listStorageKeys(
|
package/src/utils/tagsUtils.ts
CHANGED
|
@@ -14,23 +14,30 @@ export const translateTagsPageTitle = (): string =>
|
|
|
14
14
|
description: 'The title of the tag list page',
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
type TagsListItem = Readonly<{
|
|
17
|
+
export type TagsListItem = Readonly<{
|
|
18
|
+
name: string;
|
|
19
|
+
permalink: string;
|
|
20
|
+
count: number;
|
|
21
|
+
}>;
|
|
18
22
|
|
|
19
23
|
export type TagLetterEntry = Readonly<{letter: string; tags: TagsListItem[]}>;
|
|
20
24
|
|
|
21
25
|
function getTagLetter(tag: string): string {
|
|
22
|
-
return tag[0]
|
|
26
|
+
return tag[0]!.toUpperCase();
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Takes a list of tags (as provided by the content plugins), and groups them by
|
|
31
|
+
* their initials.
|
|
32
|
+
*/
|
|
25
33
|
export function listTagsByLetters(
|
|
26
34
|
tags: readonly TagsListItem[],
|
|
27
35
|
): TagLetterEntry[] {
|
|
28
|
-
|
|
29
|
-
const groups: Record<string, TagsListItem[]> = {};
|
|
36
|
+
const groups: {[initial: string]: TagsListItem[]} = {};
|
|
30
37
|
Object.values(tags).forEach((tag) => {
|
|
31
|
-
const
|
|
32
|
-
groups[
|
|
33
|
-
groups[
|
|
38
|
+
const initial = getTagLetter(tag.name);
|
|
39
|
+
groups[initial] ??= [];
|
|
40
|
+
groups[initial]!.push(tag);
|
|
34
41
|
});
|
|
35
42
|
|
|
36
43
|
return (
|
package/src/utils/tocUtils.ts
CHANGED
|
@@ -44,7 +44,7 @@ function treeifyTOC(flatTOC: readonly TOCItem[]): TOCTreeNode[] {
|
|
|
44
44
|
headings.forEach((heading) => {
|
|
45
45
|
const {parentIndex, ...rest} = heading;
|
|
46
46
|
if (parentIndex >= 0) {
|
|
47
|
-
headings[parentIndex]
|
|
47
|
+
headings[parentIndex]!.children.push(rest);
|
|
48
48
|
} else {
|
|
49
49
|
rootNodes.push(rest);
|
|
50
50
|
}
|
|
@@ -52,6 +52,10 @@ function treeifyTOC(flatTOC: readonly TOCItem[]): TOCTreeNode[] {
|
|
|
52
52
|
return rootNodes;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Takes a flat TOC list (from the MDX loader) and treeifies it into what the
|
|
57
|
+
* TOC components expect. Memoized for performance.
|
|
58
|
+
*/
|
|
55
59
|
export function useTreeifiedTOC(toc: TOCItem[]): readonly TOCTreeNode[] {
|
|
56
60
|
return useMemo(() => treeifyTOC(toc), [toc]);
|
|
57
61
|
}
|
|
@@ -87,6 +91,18 @@ function filterTOC({
|
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Takes a flat TOC list (from the MDX loader) and treeifies it into what the
|
|
96
|
+
* TOC components expect, applying the `minHeadingLevel` and `maxHeadingLevel`.
|
|
97
|
+
* Memoized for performance.
|
|
98
|
+
*
|
|
99
|
+
* **Important**: this is not the same as `useTreeifiedTOC(toc.filter(...))`,
|
|
100
|
+
* because we have to filter the TOC after it has been treeified. This is mostly
|
|
101
|
+
* to ensure that weird TOC structures preserve their semantics. For example, an
|
|
102
|
+
* h3-h2-h4 sequence should not be treeified as an "h3 > h4" hierarchy with
|
|
103
|
+
* min=3, max=4, but should rather be "[h3, h4]" (since the h2 heading has split
|
|
104
|
+
* the two headings and they are not parents)
|
|
105
|
+
*/
|
|
90
106
|
export function useFilteredAndTreeifiedTOC({
|
|
91
107
|
toc,
|
|
92
108
|
minHeadingLevel,
|
|
@@ -97,12 +113,7 @@ export function useFilteredAndTreeifiedTOC({
|
|
|
97
113
|
maxHeadingLevel: number;
|
|
98
114
|
}): readonly TOCTreeNode[] {
|
|
99
115
|
return useMemo(
|
|
100
|
-
() =>
|
|
101
|
-
// Note: we have to filter the TOC after it has been treeified. This is
|
|
102
|
-
// mostly to ensure that weird TOC structures preserve their semantics.
|
|
103
|
-
// For example, an h3-h2-h4 sequence should not be treeified as an h3 > h4
|
|
104
|
-
// hierarchy with min=3, max=4, but should rather be [h3, h4]
|
|
105
|
-
filterTOC({toc: treeifyTOC(toc), minHeadingLevel, maxHeadingLevel}),
|
|
116
|
+
() => filterTOC({toc: treeifyTOC(toc), minHeadingLevel, maxHeadingLevel}),
|
|
106
117
|
[toc, minHeadingLevel, maxHeadingLevel],
|
|
107
118
|
);
|
|
108
119
|
}
|
|
@@ -8,12 +8,26 @@
|
|
|
8
8
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
9
9
|
import {useLocation} from '@docusaurus/router';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Permits to obtain the url of the current page in another locale, useful to
|
|
13
|
+
* generate hreflang meta headers etc...
|
|
14
|
+
*
|
|
15
|
+
* @see https://developers.google.com/search/docs/advanced/crawling/localized-versions
|
|
16
|
+
*/
|
|
14
17
|
export function useAlternatePageUtils(): {
|
|
18
|
+
/**
|
|
19
|
+
* Everything (pathname, base URL, etc.) is read from the context. Just tell
|
|
20
|
+
* it which locale to link to and it will give you the alternate link for the
|
|
21
|
+
* current page.
|
|
22
|
+
*/
|
|
15
23
|
createUrl: ({
|
|
24
|
+
/** The locale name to link to. */
|
|
16
25
|
locale,
|
|
26
|
+
/**
|
|
27
|
+
* For hreflang SEO headers, we need it to be fully qualified (full
|
|
28
|
+
* protocol/domain/path...); but for locale dropdowns, using a pathname is
|
|
29
|
+
* good enough.
|
|
30
|
+
*/
|
|
17
31
|
fullyQualified,
|
|
18
32
|
}: {
|
|
19
33
|
locale: string;
|
|
@@ -46,8 +60,6 @@ export function useAlternatePageUtils(): {
|
|
|
46
60
|
fullyQualified,
|
|
47
61
|
}: {
|
|
48
62
|
locale: string;
|
|
49
|
-
// For hreflang SEO headers, we need it to be fully qualified (full
|
|
50
|
-
// protocol/domain/path...) or locale dropdown, using a path is good enough
|
|
51
63
|
fullyQualified: boolean;
|
|
52
64
|
}) {
|
|
53
65
|
return `${fullyQualified ? url : ''}${getLocalizedBaseUrl(
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
9
8
|
import {useLocation} from '@docusaurus/router';
|
|
9
|
+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Get the pathname of current route, without the optional site baseUrl.
|
|
13
|
+
* - `/docs/myDoc` => `/docs/myDoc`
|
|
14
|
+
* - `/baseUrl/docs/myDoc` => `/docs/myDoc`
|
|
15
|
+
*/
|
|
14
16
|
export function useLocalPathname(): string {
|
|
15
17
|
const {
|
|
16
18
|
siteConfig: {baseUrl},
|
|
@@ -8,17 +8,19 @@
|
|
|
8
8
|
import {useEffect} from 'react';
|
|
9
9
|
import {useLocation} from '@docusaurus/router';
|
|
10
10
|
import type {Location} from 'history';
|
|
11
|
-
import {usePrevious} from './
|
|
12
|
-
import {useDynamicCallback} from './reactUtils';
|
|
11
|
+
import {useDynamicCallback, usePrevious} from './reactUtils';
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Fires an effect when the location changes (which includes hash, query, etc.).
|
|
15
|
+
* Importantly, doesn't fire when there's no previous location: see
|
|
16
|
+
* https://github.com/facebook/docusaurus/pull/6696
|
|
17
|
+
*/
|
|
18
|
+
export function useLocationChange(
|
|
19
|
+
onLocationChange: (locationChangeEvent: {
|
|
20
|
+
location: Location;
|
|
21
|
+
previousLocation: Location | undefined;
|
|
22
|
+
}) => void,
|
|
23
|
+
): void {
|
|
22
24
|
const location = useLocation();
|
|
23
25
|
const previousLocation = usePrevious(location);
|
|
24
26
|
|
|
@@ -50,17 +50,17 @@ function createLocalePluralForms(locale: string): LocalePluralForms {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Poor man's PluralSelector implementation, using an
|
|
54
|
-
* a lightweight, future-proof and good-enough solution. We don't want a
|
|
55
|
-
* and heavy solution.
|
|
53
|
+
* Poor man's `PluralSelector` implementation, using an English fallback. We
|
|
54
|
+
* want a lightweight, future-proof and good-enough solution. We don't want a
|
|
55
|
+
* perfect and heavy solution.
|
|
56
56
|
*
|
|
57
57
|
* Docusaurus classic theme has only 2 deeply nested labels requiring complex
|
|
58
|
-
* plural rules. We don't want to use Intl + PluralRules polyfills + full
|
|
59
|
-
* syntax (react-intl) just for that.
|
|
58
|
+
* plural rules. We don't want to use `Intl` + `PluralRules` polyfills + full
|
|
59
|
+
* ICU syntax (react-intl) just for that.
|
|
60
60
|
*
|
|
61
61
|
* Notes:
|
|
62
|
-
* - 2021: 92+% Browsers support Intl.PluralRules
|
|
63
|
-
* the future
|
|
62
|
+
* - 2021: 92+% Browsers support `Intl.PluralRules`, and support will increase
|
|
63
|
+
* in the future
|
|
64
64
|
* - NodeJS >= 13 has full ICU support by default
|
|
65
65
|
* - In case of "mismatch" between SSR and Browser ICU support, React keeps
|
|
66
66
|
* working!
|
|
@@ -70,21 +70,13 @@ function useLocalePluralForms(): LocalePluralForms {
|
|
|
70
70
|
i18n: {currentLocale},
|
|
71
71
|
} = useDocusaurusContext();
|
|
72
72
|
return useMemo(() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
console.error(`Failed to use Intl.PluralRules for locale "${currentLocale}".
|
|
80
|
-
Docusaurus will fallback to a default/fallback (English) Intl.PluralRules implementation.
|
|
73
|
+
try {
|
|
74
|
+
return createLocalePluralForms(currentLocale);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.error(`Failed to use Intl.PluralRules for locale "${currentLocale}".
|
|
77
|
+
Docusaurus will fallback to the default (English) implementation.
|
|
78
|
+
Error: ${(err as Error).message}
|
|
81
79
|
`);
|
|
82
|
-
return EnglishPluralForms;
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
console.error(`Intl.PluralRules not available!
|
|
86
|
-
Docusaurus will fallback to a default/fallback (English) Intl.PluralRules implementation.
|
|
87
|
-
`);
|
|
88
80
|
return EnglishPluralForms;
|
|
89
81
|
}
|
|
90
82
|
}, [currentLocale]);
|
|
@@ -99,21 +91,32 @@ function selectPluralMessage(
|
|
|
99
91
|
const parts = pluralMessages.split(separator);
|
|
100
92
|
|
|
101
93
|
if (parts.length === 1) {
|
|
102
|
-
return parts[0]
|
|
94
|
+
return parts[0]!;
|
|
103
95
|
}
|
|
104
96
|
if (parts.length > localePluralForms.pluralForms.length) {
|
|
105
97
|
console.error(
|
|
106
|
-
`For locale=${localePluralForms.locale}, a maximum of ${localePluralForms.pluralForms.length} plural forms are expected (${localePluralForms.pluralForms}), but the message contains ${parts.length}
|
|
98
|
+
`For locale=${localePluralForms.locale}, a maximum of ${localePluralForms.pluralForms.length} plural forms are expected (${localePluralForms.pluralForms}), but the message contains ${parts.length}: ${pluralMessages}`,
|
|
107
99
|
);
|
|
108
100
|
}
|
|
109
101
|
const pluralForm = localePluralForms.select(count);
|
|
110
102
|
const pluralFormIndex = localePluralForms.pluralForms.indexOf(pluralForm);
|
|
111
103
|
// In case of not enough plural form messages, we take the last one (other)
|
|
112
104
|
// instead of returning undefined
|
|
113
|
-
return parts[Math.min(pluralFormIndex, parts.length - 1)]
|
|
105
|
+
return parts[Math.min(pluralFormIndex, parts.length - 1)]!;
|
|
114
106
|
}
|
|
115
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Reads the current locale and returns an interface very similar to
|
|
110
|
+
* `Intl.PluralRules`.
|
|
111
|
+
*/
|
|
116
112
|
export function usePluralForm(): {
|
|
113
|
+
/**
|
|
114
|
+
* Give it a `count` and it will select the relevant message from
|
|
115
|
+
* `pluralMessages`. `pluralMessages` should be separated by `|`, and in the
|
|
116
|
+
* order of "zero", "one", "two", "few", "many", "other". The actual selection
|
|
117
|
+
* is done by `Intl.PluralRules`, which tells us all plurals the locale has
|
|
118
|
+
* and which plural we should use for `count`.
|
|
119
|
+
*/
|
|
117
120
|
selectMessage: (count: number, pluralMessages: string) => string;
|
|
118
121
|
} {
|
|
119
122
|
const localePluralForm = useLocalePluralForms();
|
|
@@ -17,7 +17,7 @@ export type NavbarItem = {
|
|
|
17
17
|
items?: NavbarItem[];
|
|
18
18
|
label?: string;
|
|
19
19
|
position?: 'left' | 'right';
|
|
20
|
-
} &
|
|
20
|
+
} & {[key: string]: unknown};
|
|
21
21
|
|
|
22
22
|
export type NavbarLogo = {
|
|
23
23
|
src: string;
|
|
@@ -56,7 +56,7 @@ export type PrismConfig = {
|
|
|
56
56
|
theme?: PrismTheme;
|
|
57
57
|
darkTheme?: PrismTheme;
|
|
58
58
|
defaultLanguage?: string;
|
|
59
|
-
additionalLanguages
|
|
59
|
+
additionalLanguages: string[];
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export type FooterLinkItem = {
|
|
@@ -65,18 +65,20 @@ export type FooterLinkItem = {
|
|
|
65
65
|
href?: string;
|
|
66
66
|
html?: string;
|
|
67
67
|
prependBaseUrlToHref?: string;
|
|
68
|
+
} & {[key: string]: unknown};
|
|
69
|
+
|
|
70
|
+
export type FooterLogo = {
|
|
71
|
+
alt?: string;
|
|
72
|
+
src: string;
|
|
73
|
+
srcDark?: string;
|
|
74
|
+
width?: string | number;
|
|
75
|
+
height?: string | number;
|
|
76
|
+
href?: string;
|
|
68
77
|
};
|
|
69
78
|
|
|
70
79
|
export type FooterBase = {
|
|
71
80
|
style: 'light' | 'dark';
|
|
72
|
-
logo?:
|
|
73
|
-
alt?: string;
|
|
74
|
-
src?: string;
|
|
75
|
-
srcDark?: string;
|
|
76
|
-
width?: string | number;
|
|
77
|
-
height?: string | number;
|
|
78
|
-
href?: string;
|
|
79
|
-
};
|
|
81
|
+
logo?: FooterLogo;
|
|
80
82
|
copyright?: string;
|
|
81
83
|
};
|
|
82
84
|
|
|
@@ -117,7 +119,7 @@ export type ThemeConfig = {
|
|
|
117
119
|
hideableSidebar: boolean;
|
|
118
120
|
autoCollapseSidebarCategories: boolean;
|
|
119
121
|
image?: string;
|
|
120
|
-
metadata: Array<
|
|
122
|
+
metadata: Array<{[key: string]: string}>;
|
|
121
123
|
sidebarCollapsible: boolean;
|
|
122
124
|
tableOfContents: TableOfContents;
|
|
123
125
|
};
|
|
@@ -125,6 +127,9 @@ export type ThemeConfig = {
|
|
|
125
127
|
// User-provided theme config, unnormalized
|
|
126
128
|
export type UserThemeConfig = DeepPartial<ThemeConfig>;
|
|
127
129
|
|
|
130
|
+
/**
|
|
131
|
+
* A convenient/more semantic way to get theme config from context.
|
|
132
|
+
*/
|
|
128
133
|
export function useThemeConfig(): ThemeConfig {
|
|
129
134
|
return useDocusaurusContext().siteConfig.themeConfig as ThemeConfig;
|
|
130
135
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"announcementBarUtils.d.ts","sourceRoot":"","sources":["../../src/utils/announcementBarUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAKZ,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAMf,eAAO,MAAM,gCAAgC,oCACV,CAAC;AAapC,aAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AA8DF,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAOd;AAED,wBAAgB,kBAAkB,IAAI,kBAAkB,CAMvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"announcementBarUtils.js","sourceRoot":"","sources":["../../src/utils/announcementBarUtils.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"colorModeUtils.d.ts","sourceRoot":"","sources":["../../src/utils/colorModeUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAOf,aAAK,qBAAqB,GAAG;IAC3B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;CACnC,CAAC;AAwGF,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAWd;AAED,wBAAgB,YAAY,IAAI,qBAAqB,CAWpD"}
|