@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
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
// These class names are used to style page layouts in Docusaurus
|
|
8
|
-
// Those are meant to be targeted by user-provided custom CSS selectors
|
|
9
7
|
// Please do not modify the classnames! This is a breaking change, and annoying
|
|
10
8
|
// for users!
|
|
9
|
+
/**
|
|
10
|
+
* These class names are used to style page layouts in Docusaurus, meant to be
|
|
11
|
+
* targeted by user-provided custom CSS selectors.
|
|
12
|
+
*/
|
|
11
13
|
export const ThemeClassNames = {
|
|
12
14
|
page: {
|
|
13
15
|
blogListPage: 'blog-list-page',
|
|
@@ -25,8 +27,9 @@ export const ThemeClassNames = {
|
|
|
25
27
|
docsPages: 'docs-wrapper',
|
|
26
28
|
mdxPages: 'mdx-wrapper',
|
|
27
29
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Follows the naming convention "theme-{blog,doc,version,page}?-<suffix>"
|
|
32
|
+
*/
|
|
30
33
|
common: {
|
|
31
34
|
editThisPage: 'theme-edit-this-page',
|
|
32
35
|
lastUpdated: 'theme-last-updated',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeClassNames.js","sourceRoot":"","sources":["../../src/utils/ThemeClassNames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"ThemeClassNames.js","sourceRoot":"","sources":["../../src/utils/ThemeClassNames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+EAA+E;AAC/E,aAAa;AAEb;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE;QACJ,YAAY,EAAE,gBAAgB;QAC9B,YAAY,EAAE,gBAAgB;QAC9B,gBAAgB,EAAE,qBAAqB;QACvC,mBAAmB,EAAE,0BAA0B;QAE/C,WAAW,EAAE,eAAe;QAC5B,gBAAgB,EAAE,qBAAqB;QACvC,kBAAkB,EAAE,yBAAyB;QAE7C,OAAO,EAAE,UAAU;KACpB;IACD,OAAO,EAAE;QACP,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,cAAc;QACzB,SAAS,EAAE,cAAc;QACzB,QAAQ,EAAE,aAAa;KACxB;IAED;;OAEG;IACH,MAAM,EAAE;QACN,YAAY,EAAE,sBAAsB;QACpC,WAAW,EAAE,oBAAoB;QACjC,eAAe,EAAE,0BAA0B;QAC3C,SAAS,EAAE,kBAAkB;KAC9B;IACD,MAAM,EAAE;IACN,wCAAwC;KACzC;IACD,IAAI,EAAE;QACJ,gBAAgB,EAAE,0BAA0B;QAC5C,eAAe,EAAE,yBAAyB;QAC1C,cAAc,EAAE,uBAAuB;QACvC,WAAW,EAAE,oBAAoB;QACjC,YAAY,EAAE,sBAAsB;QACpC,aAAa,EAAE,uBAAuB;QACtC,SAAS,EAAE,kBAAkB;QAC7B,gBAAgB,EAAE,2BAA2B;QAC7C,oBAAoB,EAAE,gCAAgC;QACtD,mBAAmB,EAAE,6BAA6B;QAClD,cAAc,EAAE,wBAAwB;QACxC,sBAAsB,EAAE,iCAAiC;QACzD,kBAAkB,EAAE,6BAA6B;QACjD,2BAA2B,EAAE,CAAC,KAAa,EAAE,EAAE,CAC7C,yCAAyC,KAAK,EAAW;QAC3D,uBAAuB,EAAE,CAAC,KAAa,EAAE,EAAE,CACzC,qCAAqC,KAAK,EAAW;QACvD,wCAAwC;KACzC;IACD,IAAI,EAAE;IACJ,wCAAwC;KACzC;CACO,CAAC"}
|
|
@@ -5,13 +5,36 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
export declare function parseCodeBlockTitle(metastring?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the language name from the class name (set by MDX).
|
|
10
|
+
* e.g. `"language-javascript"` => `"javascript"`.
|
|
11
|
+
* Returns undefined if there is no language class name.
|
|
12
|
+
*/
|
|
8
13
|
export declare function parseLanguage(className: string): string | undefined;
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
15
|
+
* Parses the code content, strips away any magic comments, and returns the
|
|
16
|
+
* clean content and the highlighted lines marked by the comments or metastring.
|
|
17
|
+
*
|
|
18
|
+
* If the metastring contains highlight range, the `content` will be returned
|
|
19
|
+
* as-is without any parsing.
|
|
20
|
+
*
|
|
21
|
+
* @param content The raw code with magic comments. Trailing newline will be
|
|
22
|
+
* trimmed upfront.
|
|
23
|
+
* @param metastring The full metastring, as received from MDX. Highlight range
|
|
24
|
+
* declared here starts at 1.
|
|
25
|
+
* @param language Language of the code block, used to determine which kinds of
|
|
26
|
+
* magic comment styles to enable.
|
|
12
27
|
*/
|
|
13
28
|
export declare function parseLines(content: string, metastring?: string, language?: string): {
|
|
29
|
+
/**
|
|
30
|
+
* The highlighted lines, 0-indexed. e.g. `[0, 1, 4]` means the 1st, 2nd, and
|
|
31
|
+
* 5th lines are highlighted.
|
|
32
|
+
*/
|
|
14
33
|
highlightLines: number[];
|
|
34
|
+
/**
|
|
35
|
+
* The clean code without any magic comments (only if highlight range isn't
|
|
36
|
+
* present in the metastring).
|
|
37
|
+
*/
|
|
15
38
|
code: string;
|
|
16
39
|
};
|
|
17
40
|
//# sourceMappingURL=codeBlockUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeBlockUtils.d.ts","sourceRoot":"","sources":["../../src/utils/codeBlockUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"codeBlockUtils.d.ts","sourceRoot":"","sources":["../../src/utils/codeBlockUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgEH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB;IACD;;;OAGG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAkDA"}
|
|
@@ -6,37 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import rangeParser from 'parse-numeric-range';
|
|
8
8
|
const codeBlockTitleRegex = /title=(?<quote>["'])(?<title>.*?)\1/;
|
|
9
|
-
const highlightLinesRangeRegex =
|
|
10
|
-
const commentTypes = ['js', 'jsBlock', 'jsx', 'python', 'html'];
|
|
9
|
+
const highlightLinesRangeRegex = /\{(?<range>[\d,-]+)\}/;
|
|
11
10
|
// Supported types of highlight comments
|
|
12
11
|
const commentPatterns = {
|
|
13
|
-
js: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
start: '\\/\\*',
|
|
19
|
-
end: '\\*\\/',
|
|
20
|
-
},
|
|
21
|
-
jsx: {
|
|
22
|
-
start: '\\{\\s*\\/\\*',
|
|
23
|
-
end: '\\*\\/\\s*\\}',
|
|
24
|
-
},
|
|
25
|
-
python: {
|
|
26
|
-
start: '#',
|
|
27
|
-
end: '',
|
|
28
|
-
},
|
|
29
|
-
html: {
|
|
30
|
-
start: '<!--',
|
|
31
|
-
end: '-->',
|
|
32
|
-
},
|
|
12
|
+
js: { start: '\\/\\/', end: '' },
|
|
13
|
+
jsBlock: { start: '\\/\\*', end: '\\*\\/' },
|
|
14
|
+
jsx: { start: '\\{\\s*\\/\\*', end: '\\*\\/\\s*\\}' },
|
|
15
|
+
python: { start: '#', end: '' },
|
|
16
|
+
html: { start: '<!--', end: '-->' },
|
|
33
17
|
};
|
|
34
18
|
const magicCommentDirectives = [
|
|
35
19
|
'highlight-next-line',
|
|
36
20
|
'highlight-start',
|
|
37
21
|
'highlight-end',
|
|
38
22
|
];
|
|
39
|
-
|
|
23
|
+
function getCommentPattern(languages) {
|
|
40
24
|
// to be more reliable, the opening and closing comment must match
|
|
41
25
|
const commentPattern = languages
|
|
42
26
|
.map((lang) => {
|
|
@@ -46,31 +30,38 @@ const getMagicCommentDirectiveRegex = (languages = commentTypes) => {
|
|
|
46
30
|
.join('|');
|
|
47
31
|
// white space is allowed, but otherwise it should be on it's own line
|
|
48
32
|
return new RegExp(`^\\s*(?:${commentPattern})\\s*$`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Select comment styles based on language
|
|
36
|
+
*/
|
|
37
|
+
function getAllMagicCommentDirectiveStyles(lang) {
|
|
52
38
|
switch (lang) {
|
|
53
39
|
case 'js':
|
|
54
40
|
case 'javascript':
|
|
55
41
|
case 'ts':
|
|
56
42
|
case 'typescript':
|
|
57
|
-
return
|
|
43
|
+
return getCommentPattern(['js', 'jsBlock']);
|
|
58
44
|
case 'jsx':
|
|
59
45
|
case 'tsx':
|
|
60
|
-
return
|
|
46
|
+
return getCommentPattern(['js', 'jsBlock', 'jsx']);
|
|
61
47
|
case 'html':
|
|
62
|
-
return
|
|
48
|
+
return getCommentPattern(['js', 'jsBlock', 'html']);
|
|
63
49
|
case 'python':
|
|
64
50
|
case 'py':
|
|
65
|
-
return
|
|
51
|
+
return getCommentPattern(['python']);
|
|
66
52
|
default:
|
|
67
53
|
// all comment types
|
|
68
|
-
return
|
|
54
|
+
return getCommentPattern(Object.keys(commentPatterns));
|
|
69
55
|
}
|
|
70
|
-
}
|
|
56
|
+
}
|
|
71
57
|
export function parseCodeBlockTitle(metastring) {
|
|
72
58
|
return metastring?.match(codeBlockTitleRegex)?.groups.title ?? '';
|
|
73
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the language name from the class name (set by MDX).
|
|
62
|
+
* e.g. `"language-javascript"` => `"javascript"`.
|
|
63
|
+
* Returns undefined if there is no language class name.
|
|
64
|
+
*/
|
|
74
65
|
export function parseLanguage(className) {
|
|
75
66
|
const languageClassName = className
|
|
76
67
|
.split(' ')
|
|
@@ -78,8 +69,18 @@ export function parseLanguage(className) {
|
|
|
78
69
|
return languageClassName?.replace(/language-/, '');
|
|
79
70
|
}
|
|
80
71
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
72
|
+
* Parses the code content, strips away any magic comments, and returns the
|
|
73
|
+
* clean content and the highlighted lines marked by the comments or metastring.
|
|
74
|
+
*
|
|
75
|
+
* If the metastring contains highlight range, the `content` will be returned
|
|
76
|
+
* as-is without any parsing.
|
|
77
|
+
*
|
|
78
|
+
* @param content The raw code with magic comments. Trailing newline will be
|
|
79
|
+
* trimmed upfront.
|
|
80
|
+
* @param metastring The full metastring, as received from MDX. Highlight range
|
|
81
|
+
* declared here starts at 1.
|
|
82
|
+
* @param language Language of the code block, used to determine which kinds of
|
|
83
|
+
* magic comment styles to enable.
|
|
83
84
|
*/
|
|
84
85
|
export function parseLines(content, metastring, language) {
|
|
85
86
|
let code = content.replace(/\n$/, '');
|
|
@@ -95,7 +96,7 @@ export function parseLines(content, metastring, language) {
|
|
|
95
96
|
if (language === undefined) {
|
|
96
97
|
return { highlightLines: [], code };
|
|
97
98
|
}
|
|
98
|
-
const directiveRegex =
|
|
99
|
+
const directiveRegex = getAllMagicCommentDirectiveStyles(language);
|
|
99
100
|
// go through line by line
|
|
100
101
|
const lines = code.split('\n');
|
|
101
102
|
let highlightBlockStart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeBlockUtils.js","sourceRoot":"","sources":["../../src/utils/codeBlockUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAE9C,MAAM,mBAAmB,GAAG,qCAAqC,CAAC;AAClE,MAAM,wBAAwB,GAAG,
|
|
1
|
+
{"version":3,"file":"codeBlockUtils.js","sourceRoot":"","sources":["../../src/utils/codeBlockUtils.ts"],"names":[],"mappings":"AA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CAAC,GAAG,CAAC;oBAC/D,MAAM;gBAER;oBACE,MAAM;aACT;YACD,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;SAC7B;aAAM;YACL,yCAAyC;YACzC,UAAU,IAAI,CAAC,CAAC;SACjB;KACF;IACD,MAAM,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;IACnD,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC;AAChC,CAAC"}
|
package/lib/utils/docsUtils.d.ts
CHANGED
|
@@ -4,30 +4,37 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import type { PropSidebar, PropSidebarItem, PropSidebarItemCategory, PropVersionDoc, PropVersionMetadata, PropSidebarBreadcrumbsItem } from '@docusaurus/plugin-content-docs';
|
|
7
|
+
import type { PropSidebar, PropSidebarItem, PropSidebarItemCategory, PropVersionDoc, PropSidebarBreadcrumbsItem } from '@docusaurus/plugin-content-docs';
|
|
9
8
|
export declare const isDocsPluginEnabled: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
version: PropVersionMetadata | typeof EmptyContextValue;
|
|
14
|
-
}): JSX.Element;
|
|
15
|
-
export declare function useDocsVersion(): PropVersionMetadata;
|
|
9
|
+
/**
|
|
10
|
+
* A null-safe way to access a doc's data by ID in the active version.
|
|
11
|
+
*/
|
|
16
12
|
export declare function useDocById(id: string): PropVersionDoc;
|
|
13
|
+
/**
|
|
14
|
+
* A null-safe way to access a doc's data by ID in the active version.
|
|
15
|
+
*/
|
|
17
16
|
export declare function useDocById(id: string | undefined): PropVersionDoc | undefined;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}): JSX.Element;
|
|
22
|
-
export declare function useDocsSidebar(): PropSidebar | null;
|
|
17
|
+
/**
|
|
18
|
+
* Pure function, similar to `Array#find`, but works on the sidebar tree.
|
|
19
|
+
*/
|
|
23
20
|
export declare function findSidebarCategory(sidebar: PropSidebar, predicate: (category: PropSidebarItemCategory) => boolean): PropSidebarItemCategory | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Best effort to assign a link to a sidebar category. If the category doesn't
|
|
23
|
+
* have a link itself, we link to the first sub item with a link.
|
|
24
|
+
*/
|
|
24
25
|
export declare function findFirstCategoryLink(item: PropSidebarItemCategory): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the category associated with the current location. Should only be used
|
|
28
|
+
* on category index pages.
|
|
29
|
+
*/
|
|
25
30
|
export declare function useCurrentSidebarCategory(): PropSidebarItemCategory;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a sidebar item should be active, based on the active path.
|
|
33
|
+
*/
|
|
26
34
|
export declare function isActiveSidebarItem(item: PropSidebarItem, activePath: string): boolean;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Gets the breadcrumbs of the current doc page, based on its sidebar location.
|
|
37
|
+
* Returns `null` if there's no sidebar or breadcrumbs are disabled.
|
|
38
|
+
*/
|
|
31
39
|
export declare function useSidebarBreadcrumbs(): PropSidebarBreadcrumbsItem[] | null;
|
|
32
|
-
export {};
|
|
33
40
|
//# sourceMappingURL=docsUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/docsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"docsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/docsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AAOzC,eAAO,MAAM,mBAAmB,EAAE,OAA0B,CAAC;AAE7D;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,CAAC;AACvD;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAAC;AAa/E;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,CAAC,QAAQ,EAAE,uBAAuB,KAAK,OAAO,GACxD,uBAAuB,GAAG,SAAS,CAarC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,uBAAuB,GAC5B,MAAM,GAAG,SAAS,CAsBpB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,uBAAuB,CAenE;AASD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,eAAe,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAaT;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,0BAA0B,EAAE,GAAG,IAAI,CA6B3E"}
|
package/lib/utils/docsUtils.js
CHANGED
|
@@ -4,27 +4,13 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { useAllDocsData, useActivePlugin, } from '@docusaurus/plugin-content-docs/client';
|
|
8
|
+
import { useDocsVersion } from '../contexts/docsVersion';
|
|
9
|
+
import { useDocsSidebar } from '../contexts/docsSidebar';
|
|
10
|
+
import { isSamePath } from './routesUtils';
|
|
11
11
|
import { useLocation } from '@docusaurus/router';
|
|
12
12
|
// TODO not ideal, see also "useDocs"
|
|
13
13
|
export const isDocsPluginEnabled = !!useAllDocsData;
|
|
14
|
-
// Using a Symbol because null is a valid context value (a doc with no sidebar)
|
|
15
|
-
// Inspired by https://github.com/jamiebuilds/unstated-next/blob/master/src/unstated-next.tsx
|
|
16
|
-
const EmptyContextValue = Symbol('EmptyContext');
|
|
17
|
-
const DocsVersionContext = createContext(EmptyContextValue);
|
|
18
|
-
export function DocsVersionProvider({ children, version, }) {
|
|
19
|
-
return (React.createElement(DocsVersionContext.Provider, { value: version }, children));
|
|
20
|
-
}
|
|
21
|
-
export function useDocsVersion() {
|
|
22
|
-
const version = useContext(DocsVersionContext);
|
|
23
|
-
if (version === EmptyContextValue) {
|
|
24
|
-
throw new ReactContextError('DocsVersionProvider');
|
|
25
|
-
}
|
|
26
|
-
return version;
|
|
27
|
-
}
|
|
28
14
|
export function useDocById(id) {
|
|
29
15
|
const version = useDocsVersion();
|
|
30
16
|
if (!id) {
|
|
@@ -36,19 +22,9 @@ export function useDocById(id) {
|
|
|
36
22
|
}
|
|
37
23
|
return doc;
|
|
38
24
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
export function useDocsSidebar() {
|
|
44
|
-
const sidebar = useContext(DocsSidebarContext);
|
|
45
|
-
if (sidebar === EmptyContextValue) {
|
|
46
|
-
throw new ReactContextError('DocsSidebarProvider');
|
|
47
|
-
}
|
|
48
|
-
return sidebar;
|
|
49
|
-
}
|
|
50
|
-
// Use the components props and the sidebar in context
|
|
51
|
-
// to get back the related sidebar category that we want to render
|
|
25
|
+
/**
|
|
26
|
+
* Pure function, similar to `Array#find`, but works on the sidebar tree.
|
|
27
|
+
*/
|
|
52
28
|
export function findSidebarCategory(sidebar, predicate) {
|
|
53
29
|
for (const item of sidebar) {
|
|
54
30
|
if (item.type === 'category') {
|
|
@@ -63,7 +39,10 @@ export function findSidebarCategory(sidebar, predicate) {
|
|
|
63
39
|
}
|
|
64
40
|
return undefined;
|
|
65
41
|
}
|
|
66
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Best effort to assign a link to a sidebar category. If the category doesn't
|
|
44
|
+
* have a link itself, we link to the first sub item with a link.
|
|
45
|
+
*/
|
|
67
46
|
export function findFirstCategoryLink(item) {
|
|
68
47
|
if (item.href) {
|
|
69
48
|
return item.href;
|
|
@@ -87,6 +66,10 @@ export function findFirstCategoryLink(item) {
|
|
|
87
66
|
}
|
|
88
67
|
return undefined;
|
|
89
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Gets the category associated with the current location. Should only be used
|
|
71
|
+
* on category index pages.
|
|
72
|
+
*/
|
|
90
73
|
export function useCurrentSidebarCategory() {
|
|
91
74
|
const { pathname } = useLocation();
|
|
92
75
|
const sidebar = useDocsSidebar();
|
|
@@ -95,34 +78,42 @@ export function useCurrentSidebarCategory() {
|
|
|
95
78
|
}
|
|
96
79
|
const category = findSidebarCategory(sidebar, (item) => isSamePath(item.href, pathname));
|
|
97
80
|
if (!category) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
Hook useCurrentSidebarCategory() should only be used on Category pages`);
|
|
81
|
+
throw new Error(`${pathname} is not associated with a category. useCurrentSidebarCategory() should only be used on category index pages.`);
|
|
100
82
|
}
|
|
101
83
|
return category;
|
|
102
84
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
const isActive = (testedPath, activePath) => typeof testedPath !== 'undefined' && isSamePath(testedPath, activePath);
|
|
86
|
+
const containsActiveSidebarItem = (items, activePath) => items.some((subItem) => isActiveSidebarItem(subItem, activePath));
|
|
87
|
+
/**
|
|
88
|
+
* Checks if a sidebar item should be active, based on the active path.
|
|
89
|
+
*/
|
|
106
90
|
export function isActiveSidebarItem(item, activePath) {
|
|
107
|
-
const isActive = (testedPath) => typeof testedPath !== 'undefined' && isSamePath(testedPath, activePath);
|
|
108
91
|
if (item.type === 'link') {
|
|
109
|
-
return isActive(item.href);
|
|
92
|
+
return isActive(item.href, activePath);
|
|
110
93
|
}
|
|
111
94
|
if (item.type === 'category') {
|
|
112
|
-
return (isActive(item.href
|
|
95
|
+
return (isActive(item.href, activePath) ||
|
|
96
|
+
containsActiveSidebarItem(item.items, activePath));
|
|
113
97
|
}
|
|
114
98
|
return false;
|
|
115
99
|
}
|
|
116
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Gets the breadcrumbs of the current doc page, based on its sidebar location.
|
|
102
|
+
* Returns `null` if there's no sidebar or breadcrumbs are disabled.
|
|
103
|
+
*/
|
|
104
|
+
export function useSidebarBreadcrumbs() {
|
|
105
|
+
const sidebar = useDocsSidebar();
|
|
106
|
+
const { pathname } = useLocation();
|
|
107
|
+
const breadcrumbsOption = useActivePlugin()?.pluginData.breadcrumbs;
|
|
108
|
+
if (breadcrumbsOption === false || !sidebar) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
117
111
|
const breadcrumbs = [];
|
|
118
112
|
function extract(items) {
|
|
119
113
|
for (const item of items) {
|
|
120
|
-
if (item.type === 'category' &&
|
|
121
|
-
(isSamePath(item.href, pathname) || extract(item.items)))
|
|
122
|
-
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
else if (item.type === 'link' && isSamePath(item.href, pathname)) {
|
|
114
|
+
if ((item.type === 'category' &&
|
|
115
|
+
(isSamePath(item.href, pathname) || extract(item.items))) ||
|
|
116
|
+
(item.type === 'link' && isSamePath(item.href, pathname))) {
|
|
126
117
|
breadcrumbs.push(item);
|
|
127
118
|
return true;
|
|
128
119
|
}
|
|
@@ -132,13 +123,4 @@ export function getBreadcrumbs({ sidebar, pathname, }) {
|
|
|
132
123
|
extract(sidebar);
|
|
133
124
|
return breadcrumbs.reverse();
|
|
134
125
|
}
|
|
135
|
-
export function useSidebarBreadcrumbs() {
|
|
136
|
-
const sidebar = useDocsSidebar();
|
|
137
|
-
const { pathname } = useLocation();
|
|
138
|
-
const breadcrumbsOption = useActivePlugin()?.pluginData.breadcrumbs;
|
|
139
|
-
if (breadcrumbsOption === false || !sidebar) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
return getBreadcrumbs({ sidebar, pathname });
|
|
143
|
-
}
|
|
144
126
|
//# sourceMappingURL=docsUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docsUtils.js","sourceRoot":"","sources":["../../src/utils/docsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"docsUtils.js","sourceRoot":"","sources":["../../src/utils/docsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,GAChB,MAAM,wCAAwC,CAAC;AAQhD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,qCAAqC;AACrC,MAAM,CAAC,MAAM,mBAAmB,GAAY,CAAC,CAAC,cAAc,CAAC;AAU7D,MAAM,UAAU,UAAU,CAAC,EAAsB;IAC/C,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,EAAE;QACP,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;KACrD;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAoB,EACpB,SAAyD;IAEzD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;QAC1B,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YAC5B,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE;gBACnB,OAAO,IAAI,CAAC;aACb;YACD,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAA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B,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC3D,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,EACzD;gBACA,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACvB,OAAO,IAAI,CAAC;aACb;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjB,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { MultiColumnFooter, SimpleFooter } from './useThemeConfig';
|
|
8
|
+
/**
|
|
9
|
+
* A rough duck-typing about whether the `footer.links` is intended to be multi-
|
|
10
|
+
* column.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isMultiColumnFooterLinks(links: MultiColumnFooter['links'] | SimpleFooter['links']): links is MultiColumnFooter['links'];
|
|
13
|
+
//# sourceMappingURL=footerUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footerUtils.d.ts","sourceRoot":"","sources":["../../src/utils/footerUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,GACxD,KAAK,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAErC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A rough duck-typing about whether the `footer.links` is intended to be multi-
|
|
9
|
+
* column.
|
|
10
|
+
*/
|
|
11
|
+
export function isMultiColumnFooterLinks(links) {
|
|
12
|
+
return 'title' in links[0];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=footerUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footerUtils.js","sourceRoot":"","sources":["../../src/utils/footerUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAyD;IAEzD,OAAO,OAAO,IAAI,KAAK,CAAC,CAAC,CAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Formats the page's title based on relevant site config and other contexts.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useTitleFormatter(title?: string | undefined): string;
|
|
8
11
|
//# sourceMappingURL=generalUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,
|
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMpE"}
|
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Formats the page's title based on relevant site config and other contexts.
|
|
10
|
+
*/
|
|
11
|
+
export function useTitleFormatter(title) {
|
|
9
12
|
const { siteConfig } = useDocusaurusContext();
|
|
10
13
|
const { title: siteTitle, titleDelimiter } = siteConfig;
|
|
11
|
-
return title
|
|
14
|
+
return title?.trim().length
|
|
12
15
|
? `${title.trim()} ${titleDelimiter} ${siteTitle}`
|
|
13
16
|
: siteTitle;
|
|
14
|
-
}
|
|
17
|
+
}
|
|
15
18
|
//# sourceMappingURL=generalUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generalUtils.js","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAEpE,MAAM,
|
|
1
|
+
{"version":3,"file":"generalUtils.js","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA0B;IAC1D,MAAM,EAAC,UAAU,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAC5C,MAAM,EAAC,KAAK,EAAE,SAAS,EAAE,cAAc,EAAC,GAAG,UAAU,CAAC;IACtD,OAAO,KAAK,EAAE,IAAI,EAAE,CAAC,MAAM;QACzB,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,cAAc,IAAI,SAAS,EAAE;QAClD,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -6,15 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Location, Action } from 'history';
|
|
8
8
|
declare type HistoryBlockHandler = (location: Location, action: Action) => void | false;
|
|
9
|
-
/**
|
|
10
|
-
* Permits to register a handler that will be called on history actions (pop,
|
|
11
|
-
* push, replace) If the handler returns false, the navigation transition will
|
|
12
|
-
* be blocked/cancelled
|
|
13
|
-
*/
|
|
14
|
-
export declare function useHistoryActionHandler(handler: HistoryBlockHandler): void;
|
|
15
9
|
/**
|
|
16
10
|
* Permits to register a handler that will be called on history pop navigation
|
|
17
|
-
* (backward/forward) If the handler returns false
|
|
11
|
+
* (backward/forward). If the handler returns `false`, the backward/forward
|
|
18
12
|
* transition will be blocked. Unfortunately there's no good way to detect the
|
|
19
13
|
* "direction" (backward/forward) of the POP event.
|
|
20
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"historyUtils.d.ts","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"historyUtils.d.ts","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,SAAS,CAAC;AAE9C,aAAK,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,KAAK,CAAC;AAiBhF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CASvE"}
|
|
@@ -4,34 +4,31 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import { useEffect
|
|
7
|
+
import { useEffect } from 'react';
|
|
8
8
|
import { useHistory } from '@docusaurus/router';
|
|
9
|
+
import { useDynamicCallback } from './reactUtils';
|
|
9
10
|
/**
|
|
10
11
|
* Permits to register a handler that will be called on history actions (pop,
|
|
11
|
-
* push, replace) If the handler returns false
|
|
12
|
-
* be blocked/cancelled
|
|
12
|
+
* push, replace). If the handler returns `false`, the navigation transition
|
|
13
|
+
* will be blocked/cancelled.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
function useHistoryActionHandler(handler) {
|
|
15
16
|
const { block } = useHistory();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
lastHandlerRef.current = handler;
|
|
20
|
-
}, [handler]);
|
|
21
|
-
useEffect(() =>
|
|
17
|
+
const stableHandler = useDynamicCallback(handler);
|
|
18
|
+
useEffect(
|
|
22
19
|
// See https://github.com/remix-run/history/blob/main/docs/blocking-transitions.md
|
|
23
|
-
block((location, action) =>
|
|
20
|
+
() => block((location, action) => stableHandler(location, action)), [block, stableHandler]);
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* Permits to register a handler that will be called on history pop navigation
|
|
27
|
-
* (backward/forward) If the handler returns false
|
|
24
|
+
* (backward/forward). If the handler returns `false`, the backward/forward
|
|
28
25
|
* transition will be blocked. Unfortunately there's no good way to detect the
|
|
29
26
|
* "direction" (backward/forward) of the POP event.
|
|
30
27
|
*/
|
|
31
28
|
export function useHistoryPopHandler(handler) {
|
|
32
29
|
useHistoryActionHandler((location, action) => {
|
|
33
30
|
if (action === 'POP') {
|
|
34
|
-
//
|
|
31
|
+
// Maybe block navigation if handler returns false
|
|
35
32
|
return handler(location, action);
|
|
36
33
|
}
|
|
37
34
|
// Don't block other navigation actions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"historyUtils.js","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"historyUtils.js","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAKhD;;;;GAIG;AACH,SAAS,uBAAuB,CAAC,OAA4B;IAC3D,MAAM,EAAC,KAAK,EAAC,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClD,SAAS;IACP,kFAAkF;IAClF,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,EAClE,CAAC,KAAK,EAAE,aAAa,CAAC,CACvB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA4B;IAC/D,uBAAuB,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,kDAAkD;YAClD,OAAO,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;SAClC;QACD,uCAAuC;QACvC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/lib/utils/jsUtils.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function duplicates<T>(arr: readonly T[], comparator?: (a: T, b: T) => boolean): T[];
|
|
17
17
|
/**
|
|
18
|
-
* Remove duplicate array items (similar to _.uniq)
|
|
18
|
+
* Remove duplicate array items (similar to `_.uniq`)
|
|
19
19
|
* @param arr The array.
|
|
20
20
|
* @returns An array with duplicate elements removed by reference comparison.
|
|
21
21
|
*/
|