@docusaurus/theme-classic 2.0.0-beta.138b4c997 → 2.0.0-beta.14
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/README.md +1 -1
- package/lib/admonitions.css +35 -0
- package/lib/deps.d.ts +13 -0
- package/lib/index.js +16 -15
- package/lib/prism-include-languages.js +9 -5
- package/{lib-next/types.d.ts → lib/theme-classic.d.ts} +374 -150
- package/lib/translations.js +16 -7
- package/lib/types.d.ts +0 -587
- package/lib/validateThemeConfig.js +232 -246
- package/lib-next/theme/Admonition/index.js +101 -0
- package/lib-next/theme/AnnouncementBar/index.js +7 -12
- package/lib-next/theme/AnnouncementBar/styles.module.css +23 -32
- package/lib-next/theme/BackToTopButton/index.js +131 -0
- package/lib-next/theme/BackToTopButton/styles.module.css +42 -0
- package/lib-next/theme/BlogArchivePage/index.js +80 -0
- package/lib-next/theme/BlogLayout/index.js +40 -0
- package/lib-next/theme/BlogListPage/index.js +17 -25
- package/lib-next/theme/BlogPostAuthor/index.js +46 -0
- package/{lib/theme/MDXPage → lib-next/theme/BlogPostAuthor}/styles.module.css +4 -2
- package/lib-next/theme/BlogPostAuthors/index.js +34 -0
- package/{lib/theme/IconExternalLink → lib-next/theme/BlogPostAuthors}/styles.module.css +3 -4
- package/lib-next/theme/BlogPostItem/index.js +79 -86
- package/lib-next/theme/BlogPostPage/index.js +70 -35
- package/lib-next/theme/BlogSidebar/index.js +11 -13
- package/lib-next/theme/BlogSidebar/styles.module.css +2 -2
- package/lib-next/theme/BlogTagsListPage/index.js +14 -55
- package/lib-next/theme/BlogTagsPostsPage/index.js +29 -39
- package/lib-next/theme/CodeBlock/index.js +23 -149
- package/lib-next/theme/CodeBlock/styles.module.css +12 -9
- package/lib-next/theme/Details/index.js +20 -0
- package/lib-next/theme/Details/styles.module.css +13 -0
- package/lib-next/theme/DocCard/index.js +80 -0
- package/lib-next/theme/DocCard/styles.module.css +43 -0
- package/lib-next/theme/DocCardList/index.js +19 -0
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +49 -0
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +18 -0
- package/lib-next/theme/DocItem/index.js +40 -51
- package/lib-next/theme/DocItem/styles.module.css +5 -9
- package/lib-next/theme/DocItemFooter/index.js +79 -0
- package/{lib/theme/DocItem → lib-next/theme/DocItemFooter}/styles.module.css +1 -9
- package/lib-next/theme/DocPage/index.js +46 -49
- package/lib-next/theme/DocPage/styles.module.css +5 -6
- package/lib-next/theme/DocPaginator/index.js +5 -33
- package/lib-next/theme/DocPaginatorNavLink/index.js +36 -0
- package/lib-next/theme/DocSidebar/index.js +65 -285
- package/lib-next/theme/DocSidebar/styles.module.css +0 -18
- package/lib-next/theme/DocSidebarItem/index.js +217 -0
- package/{lib/theme/ThemedImage → lib-next/theme/DocSidebarItem}/styles.module.css +10 -9
- package/lib-next/theme/DocTagDocListPage/index.js +89 -0
- package/lib-next/theme/DocTagsListPage/index.js +38 -0
- package/lib-next/theme/DocVersionBadge/index.js +27 -0
- package/lib-next/theme/DocVersionBanner/index.js +28 -14
- package/lib-next/theme/EditThisPage/index.js +6 -1
- package/lib-next/theme/ErrorPageContent.js +35 -0
- package/lib-next/theme/Footer/index.js +100 -40
- package/lib-next/theme/Heading/index.js +24 -29
- package/lib-next/theme/Heading/styles.css +5 -6
- package/lib-next/theme/Heading/styles.module.css +9 -5
- package/lib-next/theme/IconArrow/index.js +2 -2
- package/lib-next/theme/IconClose/index.js +23 -0
- package/lib-next/theme/IconEdit/index.js +2 -2
- package/lib-next/theme/IconExternalLink/index.js +2 -2
- package/lib-next/theme/IconLanguage/index.js +2 -2
- package/lib-next/theme/IconMenu/index.js +2 -2
- package/lib-next/theme/LastUpdated/index.js +3 -2
- package/lib-next/theme/Layout/index.js +3 -1
- package/lib-next/theme/LayoutHead/index.js +18 -23
- package/lib-next/theme/LayoutProviders/index.js +9 -3
- package/lib-next/theme/Logo/index.js +25 -21
- package/lib-next/theme/MDXComponents/index.js +34 -7
- package/{lib/theme/hooks → lib-next/theme/MDXComponents}/styles.css +3 -2
- package/lib-next/theme/MDXPage/index.js +10 -2
- package/lib-next/theme/Navbar/index.js +193 -56
- package/lib-next/theme/Navbar/styles.module.css +10 -3
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +45 -147
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +7 -7
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +31 -19
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +158 -0
- package/lib-next/theme/NavbarItem/{LocaleDropdownNavbarItem.js → LocaleDropdownNavbarItem/index.js} +4 -12
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
- package/lib-next/theme/NavbarItem/index.js +25 -12
- package/lib-next/theme/{SearchMetadatas → SearchMetadata}/index.js +1 -1
- package/lib-next/theme/Seo/index.js +11 -7
- package/lib-next/theme/SkipToContent/index.js +5 -2
- package/lib-next/theme/TOC/index.js +12 -36
- package/lib-next/theme/TOC/styles.module.css +1 -1
- package/lib-next/theme/TOCCollapsible/index.js +54 -0
- package/lib-next/theme/TOCCollapsible/styles.module.css +50 -0
- package/lib-next/theme/TOCInline/index.js +10 -28
- package/lib-next/theme/TOCItems/index.js +85 -0
- package/lib-next/theme/Tabs/__tests__/index.test.js +142 -0
- package/lib-next/theme/Tabs/index.js +103 -48
- package/lib-next/theme/Tabs/styles.module.css +0 -13
- package/lib-next/theme/Tag/index.js +27 -0
- package/lib-next/theme/Tag/styles.module.css +70 -0
- package/lib-next/theme/TagsListByLetter/index.js +42 -0
- package/lib-next/theme/TagsListByLetter/styles.module.css +11 -0
- package/lib-next/theme/TagsListInline/index.js +31 -0
- package/lib-next/theme/TagsListInline/styles.module.css +15 -0
- package/lib-next/theme/ThemeProvider/index.js +10 -7
- package/lib-next/theme/ThemedImage/index.js +5 -5
- package/lib-next/theme/Toggle/index.js +34 -37
- package/lib-next/theme/Toggle/styles.module.css +91 -3
- package/lib-next/theme/UserPreferencesProvider/index.js +9 -6
- package/lib-next/theme/hooks/useHideableNavbar.js +31 -44
- package/lib-next/theme/hooks/useTheme.js +4 -5
- package/lib-next/theme/hooks/useWindowSize.js +34 -20
- package/lib-next/theme/prism-include-languages.js +2 -1
- package/package.json +27 -25
- package/src/admonitions.css +35 -0
- package/src/deps.d.ts +13 -0
- package/src/index.ts +23 -20
- package/{lib-next/prism-include-languages.js → src/prism-include-languages.ts} +0 -0
- package/src/theme/Admonition/index.tsx +106 -0
- package/src/theme/AnnouncementBar/index.tsx +8 -12
- package/src/theme/AnnouncementBar/styles.module.css +23 -32
- package/src/theme/BackToTopButton/index.tsx +142 -0
- package/src/theme/BackToTopButton/styles.module.css +42 -0
- package/src/theme/BlogArchivePage/index.tsx +91 -0
- package/src/theme/BlogLayout/index.tsx +44 -0
- package/src/theme/BlogListPage/index.tsx +18 -25
- package/src/theme/BlogPostAuthor/index.tsx +49 -0
- package/{lib/theme/IconEdit → src/theme/BlogPostAuthor}/styles.module.css +4 -3
- package/src/theme/BlogPostAuthors/index.tsx +39 -0
- package/src/theme/BlogPostAuthors/styles.module.css +11 -0
- package/src/theme/BlogPostItem/index.tsx +70 -80
- package/src/theme/BlogPostPage/index.tsx +72 -35
- package/src/theme/BlogSidebar/index.tsx +11 -13
- package/src/theme/BlogSidebar/styles.module.css +2 -2
- package/src/theme/BlogTagsListPage/index.tsx +14 -57
- package/src/theme/BlogTagsPostsPage/index.tsx +29 -39
- package/src/theme/CodeBlock/index.tsx +27 -151
- package/src/theme/CodeBlock/styles.module.css +12 -9
- package/src/theme/Details/index.tsx +24 -0
- package/src/theme/Details/styles.module.css +13 -0
- package/src/theme/DocCard/index.tsx +100 -0
- package/src/theme/DocCard/styles.module.css +43 -0
- package/src/theme/DocCardList/index.tsx +27 -0
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +53 -0
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +18 -0
- package/src/theme/DocItem/index.tsx +43 -51
- package/src/theme/DocItem/styles.module.css +5 -9
- package/src/theme/DocItemFooter/index.tsx +91 -0
- package/{lib/theme/BlogPostItem → src/theme/DocItemFooter}/styles.module.css +8 -8
- package/src/theme/DocPage/index.tsx +44 -42
- package/src/theme/DocPage/styles.module.css +5 -6
- package/src/theme/DocPaginator/index.tsx +5 -33
- package/src/theme/DocPaginatorNavLink/index.tsx +38 -0
- package/src/theme/DocSidebar/index.tsx +76 -297
- package/src/theme/DocSidebar/styles.module.css +0 -18
- package/src/theme/DocSidebarItem/index.tsx +242 -0
- package/{lib/theme/Footer → src/theme/DocSidebarItem}/styles.module.css +10 -6
- package/src/theme/DocTagDocListPage/index.tsx +89 -0
- package/src/theme/DocTagsListPage/index.tsx +41 -0
- package/src/theme/DocVersionBadge/index.tsx +30 -0
- package/src/theme/DocVersionBanner/index.tsx +48 -21
- package/src/theme/EditThisPage/index.tsx +6 -1
- package/src/theme/ErrorPageContent.tsx +41 -0
- package/src/theme/Footer/index.tsx +113 -43
- package/src/theme/Heading/index.tsx +24 -31
- package/src/theme/Heading/styles.css +5 -6
- package/src/theme/Heading/styles.module.css +9 -5
- package/src/theme/IconArrow/index.tsx +2 -2
- package/src/theme/IconClose/index.tsx +26 -0
- package/src/theme/IconEdit/index.tsx +2 -2
- package/src/theme/IconExternalLink/index.tsx +2 -5
- package/src/theme/IconLanguage/index.tsx +2 -6
- package/src/theme/IconMenu/index.tsx +3 -3
- package/src/theme/LastUpdated/index.tsx +3 -2
- package/src/theme/Layout/index.tsx +3 -1
- package/src/theme/LayoutHead/index.tsx +18 -17
- package/src/theme/LayoutProviders/index.tsx +9 -3
- package/src/theme/Logo/index.tsx +21 -17
- package/src/theme/MDXComponents/index.tsx +39 -5
- package/src/theme/MDXComponents/styles.css +11 -0
- package/src/theme/MDXPage/index.tsx +10 -2
- package/src/theme/Navbar/index.tsx +203 -61
- package/src/theme/Navbar/styles.module.css +10 -3
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +42 -154
- package/src/theme/NavbarItem/DocNavbarItem.tsx +12 -16
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +33 -21
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +7 -3
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +180 -0
- package/src/theme/NavbarItem/{LocaleDropdownNavbarItem.tsx → LocaleDropdownNavbarItem/index.tsx} +8 -9
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
- package/src/theme/NavbarItem/index.tsx +41 -16
- package/src/theme/{SearchMetadatas → SearchMetadata}/index.tsx +2 -2
- package/src/theme/Seo/index.tsx +7 -4
- package/src/theme/SkipToContent/index.tsx +5 -2
- package/src/theme/TOC/index.tsx +12 -41
- package/src/theme/TOC/styles.module.css +1 -1
- package/src/theme/TOCCollapsible/index.tsx +58 -0
- package/src/theme/TOCCollapsible/styles.module.css +50 -0
- package/src/theme/TOCInline/index.tsx +13 -32
- package/src/theme/TOCItems/index.tsx +96 -0
- package/src/theme/Tabs/index.tsx +110 -54
- package/src/theme/Tabs/styles.module.css +0 -13
- package/src/theme/Tag/index.tsx +31 -0
- package/src/theme/Tag/styles.module.css +70 -0
- package/src/theme/TagsListByLetter/index.tsx +45 -0
- package/src/theme/TagsListByLetter/styles.module.css +11 -0
- package/src/theme/TagsListInline/index.tsx +35 -0
- package/src/theme/TagsListInline/styles.module.css +15 -0
- package/src/theme/ThemeProvider/index.tsx +6 -2
- package/src/theme/ThemedImage/index.tsx +5 -5
- package/src/theme/Toggle/index.tsx +36 -43
- package/src/theme/Toggle/styles.module.css +91 -3
- package/src/theme/UserPreferencesProvider/index.tsx +9 -6
- package/src/theme/hooks/useHideableNavbar.ts +32 -45
- package/src/theme/hooks/useTabGroupChoice.ts +2 -2
- package/src/theme/hooks/useTheme.ts +4 -5
- package/src/theme/hooks/useWindowSize.ts +38 -20
- package/src/theme/prism-include-languages.ts +3 -2
- package/src/theme-classic.d.ts +822 -0
- package/src/translations.ts +41 -23
- package/src/types.d.ts +0 -587
- package/src/{validateThemeConfig.js → validateThemeConfig.ts} +160 -98
- package/babel.config.js +0 -35
- package/codeTranslations/README.md +0 -20
- package/codeTranslations/ar.json +0 -57
- package/codeTranslations/base.json +0 -112
- package/codeTranslations/bn.json +0 -56
- package/codeTranslations/da.json +0 -57
- package/codeTranslations/de.json +0 -57
- package/codeTranslations/es.json +0 -57
- package/codeTranslations/fa.json +0 -57
- package/codeTranslations/fil.json +0 -57
- package/codeTranslations/fr.json +0 -57
- package/codeTranslations/he.json +0 -57
- package/codeTranslations/hi.json +0 -57
- package/codeTranslations/ja.json +0 -57
- package/codeTranslations/ko.json +0 -57
- package/codeTranslations/pl.json +0 -57
- package/codeTranslations/pt-BR.json +0 -57
- package/codeTranslations/pt-PT.json +0 -57
- package/codeTranslations/ru.json +0 -57
- package/codeTranslations/tr.json +0 -57
- package/codeTranslations/vi.json +0 -57
- package/codeTranslations/zh-Hans.json +0 -57
- package/codeTranslations/zh-Hant.json +0 -57
- package/lib/__tests__/__snapshots__/translations.test.ts.snap +0 -116
- package/lib/__tests__/translations.test.js +0 -112
- package/lib/__tests__/validateThemeConfig.test.js +0 -333
- package/lib/theme/AnnouncementBar/index.js +0 -72
- package/lib/theme/AnnouncementBar/styles.module.css +0 -72
- package/lib/theme/BlogListPage/index.js +0 -71
- package/lib/theme/BlogListPaginator/index.js +0 -63
- package/lib/theme/BlogPostItem/index.js +0 -161
- package/lib/theme/BlogPostPage/index.js +0 -69
- package/lib/theme/BlogPostPaginator/index.js +0 -64
- package/lib/theme/BlogSidebar/index.js +0 -51
- package/lib/theme/BlogSidebar/styles.module.css +0 -44
- package/lib/theme/BlogTagsListPage/index.js +0 -76
- package/lib/theme/BlogTagsPostsPage/index.js +0 -100
- package/lib/theme/CodeBlock/index.js +0 -253
- package/lib/theme/CodeBlock/styles.module.css +0 -68
- package/lib/theme/DocItem/index.js +0 -129
- package/lib/theme/DocPage/index.js +0 -173
- package/lib/theme/DocPage/styles.module.css +0 -86
- package/lib/theme/DocPaginator/index.js +0 -63
- package/lib/theme/DocSidebar/index.js +0 -306
- package/lib/theme/DocSidebar/styles.module.css +0 -124
- package/lib/theme/DocVersionBanner/index.js +0 -128
- package/lib/theme/EditThisPage/index.js +0 -31
- package/lib/theme/Footer/index.js +0 -108
- package/lib/theme/Heading/index.js +0 -76
- package/lib/theme/Heading/styles.css +0 -23
- package/lib/theme/Heading/styles.module.css +0 -15
- package/lib/theme/IconArrow/index.js +0 -28
- package/lib/theme/IconEdit/index.js +0 -34
- package/lib/theme/IconExternalLink/index.js +0 -30
- package/lib/theme/IconLanguage/index.js +0 -29
- package/lib/theme/IconMenu/index.js +0 -30
- package/lib/theme/LastUpdated/index.js +0 -61
- package/lib/theme/Layout/index.js +0 -64
- package/lib/theme/Layout/styles.css +0 -27
- package/lib/theme/LayoutHead/index.js +0 -144
- package/lib/theme/LayoutProviders/index.js +0 -36
- package/lib/theme/Logo/index.js +0 -60
- package/lib/theme/MDXComponents/index.js +0 -65
- package/lib/theme/MDXPage/index.js +0 -66
- package/lib/theme/Navbar/index.js +0 -147
- package/lib/theme/Navbar/styles.module.css +0 -20
- package/lib/theme/NavbarItem/DefaultNavbarItem.js +0 -209
- package/lib/theme/NavbarItem/DocNavbarItem.js +0 -63
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -76
- package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +0 -43
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem.js +0 -72
- package/lib/theme/NavbarItem/SearchNavbarItem.js +0 -28
- package/lib/theme/NavbarItem/index.js +0 -54
- package/lib/theme/NotFound.js +0 -57
- package/lib/theme/SearchBar.js +0 -15
- package/lib/theme/SearchMetadatas/index.js +0 -33
- package/lib/theme/Seo/index.js +0 -49
- package/lib/theme/SkipToContent/index.js +0 -63
- package/lib/theme/SkipToContent/styles.module.css +0 -14
- package/lib/theme/TOC/index.js +0 -59
- package/lib/theme/TOC/styles.module.css +0 -23
- package/lib/theme/TOCInline/index.js +0 -53
- package/lib/theme/TOCInline/styles.module.css +0 -12
- package/lib/theme/TabItem/index.js +0 -32
- package/lib/theme/Tabs/index.js +0 -150
- package/lib/theme/Tabs/styles.module.css +0 -23
- package/lib/theme/ThemeContext.js +0 -21
- package/lib/theme/ThemeProvider/index.js +0 -38
- package/lib/theme/ThemedImage/index.js +0 -49
- package/lib/theme/Toggle/index.js +0 -94
- package/lib/theme/Toggle/styles.css +0 -103
- package/lib/theme/Toggle/styles.module.css +0 -17
- package/lib/theme/UserPreferencesContext.js +0 -18
- package/lib/theme/UserPreferencesProvider/index.js +0 -36
- package/lib/theme/hooks/useContextualSearchFilters.js +0 -47
- package/lib/theme/hooks/useDocs.js +0 -18
- package/lib/theme/hooks/useHideableNavbar.js +0 -92
- package/lib/theme/hooks/useKeyboardNavigation.js +0 -45
- package/lib/theme/hooks/useLocationHash.js +0 -28
- package/lib/theme/hooks/useLockBodyScroll.js +0 -26
- package/lib/theme/hooks/usePrismTheme.js +0 -36
- package/lib/theme/hooks/useScrollPosition.js +0 -49
- package/lib/theme/hooks/useTOCHighlight.js +0 -87
- package/lib/theme/hooks/useTabGroupChoice.js +0 -51
- package/lib/theme/hooks/useTheme.js +0 -99
- package/lib/theme/hooks/useThemeContext.js +0 -31
- package/lib/theme/hooks/useUserPreferencesContext.js +0 -31
- package/lib/theme/hooks/useWindowSize.js +0 -55
- package/lib/theme/prism-include-languages.js +0 -39
- package/lib-next/__tests__/__snapshots__/translations.test.ts.snap +0 -116
- package/lib-next/__tests__/translations.test.js +0 -128
- package/lib-next/__tests__/validateThemeConfig.test.js +0 -333
- package/lib-next/index.js +0 -221
- package/lib-next/theme/Toggle/styles.css +0 -103
- package/lib-next/theme/hooks/useContextualSearchFilters.js +0 -41
- package/lib-next/theme/hooks/useLocationHash.js +0 -20
- package/lib-next/theme/hooks/useScrollPosition.js +0 -38
- package/lib-next/theme/hooks/useTOCHighlight.js +0 -84
- package/lib-next/translations.js +0 -145
- package/lib-next/validateThemeConfig.js +0 -317
- package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -116
- package/src/__tests__/translations.test.ts +0 -116
- package/src/__tests__/validateThemeConfig.test.js +0 -333
- package/src/prism-include-languages.js +0 -11
- package/src/theme/Toggle/styles.css +0 -103
- package/src/theme/hooks/useContextualSearchFilters.ts +0 -52
- package/src/theme/hooks/useLocationHash.ts +0 -25
- package/src/theme/hooks/useScrollPosition.ts +0 -45
- package/src/theme/hooks/useTOCHighlight.ts +0 -98
- package/tsconfig.json +0 -12
- package/update-code-translations.js +0 -240
- package/update-code-translations.test.js +0 -33
|
@@ -1,20 +0,0 @@
|
|
|
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 {useState, useEffect} from 'react';
|
|
8
|
-
|
|
9
|
-
function useLocationHash(initialHash) {
|
|
10
|
-
const [hash, setHash] = useState(initialHash);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const handleHashChange = () => setHash(window.location.hash);
|
|
13
|
-
|
|
14
|
-
window.addEventListener('hashchange', handleHashChange);
|
|
15
|
-
return () => window.removeEventListener('hashchange', handleHashChange);
|
|
16
|
-
}, []);
|
|
17
|
-
return [hash, setHash];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default useLocationHash;
|
|
@@ -1,38 +0,0 @@
|
|
|
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 {useEffect, useRef} from 'react';
|
|
8
|
-
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
9
|
-
|
|
10
|
-
const getScrollPosition = () => ({
|
|
11
|
-
scrollX: ExecutionEnvironment.canUseDOM ? window.pageXOffset : 0,
|
|
12
|
-
scrollY: ExecutionEnvironment.canUseDOM ? window.pageYOffset : 0,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const useScrollPosition = (effect, deps = []) => {
|
|
16
|
-
const scrollPosition = useRef(getScrollPosition());
|
|
17
|
-
|
|
18
|
-
const handleScroll = () => {
|
|
19
|
-
const currentScrollPosition = getScrollPosition();
|
|
20
|
-
|
|
21
|
-
if (effect) {
|
|
22
|
-
effect(currentScrollPosition, scrollPosition.current);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
scrollPosition.current = currentScrollPosition;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const opts = {
|
|
30
|
-
passive: true,
|
|
31
|
-
};
|
|
32
|
-
handleScroll();
|
|
33
|
-
window.addEventListener('scroll', handleScroll, opts);
|
|
34
|
-
return () => window.removeEventListener('scroll', handleScroll, opts);
|
|
35
|
-
}, deps);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default useScrollPosition;
|
|
@@ -1,84 +0,0 @@
|
|
|
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 {useEffect, useState} from 'react';
|
|
8
|
-
|
|
9
|
-
function useTOCHighlight(linkClassName, linkActiveClassName, topOffset) {
|
|
10
|
-
const [lastActiveLink, setLastActiveLink] = useState(undefined);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
function setActiveLink() {
|
|
13
|
-
function getActiveHeaderAnchor() {
|
|
14
|
-
const headersAnchors = Array.from(
|
|
15
|
-
document.getElementsByClassName('anchor'),
|
|
16
|
-
);
|
|
17
|
-
const firstAnchorUnderViewportTop = headersAnchors.find((anchor) => {
|
|
18
|
-
const {top} = anchor.getBoundingClientRect();
|
|
19
|
-
return top >= topOffset;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (firstAnchorUnderViewportTop) {
|
|
23
|
-
// If first anchor in viewport is under a certain threshold, we consider it's not the active anchor.
|
|
24
|
-
// In such case, the active anchor is the previous one (if it exists), that may be above the viewport
|
|
25
|
-
if (
|
|
26
|
-
firstAnchorUnderViewportTop.getBoundingClientRect().top >= topOffset
|
|
27
|
-
) {
|
|
28
|
-
const previousAnchor =
|
|
29
|
-
headersAnchors[
|
|
30
|
-
headersAnchors.indexOf(firstAnchorUnderViewportTop) - 1
|
|
31
|
-
];
|
|
32
|
-
return previousAnchor ?? firstAnchorUnderViewportTop;
|
|
33
|
-
} // If the anchor is at the top of the viewport, we consider it's the first anchor
|
|
34
|
-
else {
|
|
35
|
-
return firstAnchorUnderViewportTop;
|
|
36
|
-
}
|
|
37
|
-
} // no anchor under viewport top? (ie we are at the bottom of the page)
|
|
38
|
-
else {
|
|
39
|
-
// highlight the last anchor found
|
|
40
|
-
return headersAnchors[headersAnchors.length - 1];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const activeHeaderAnchor = getActiveHeaderAnchor();
|
|
45
|
-
|
|
46
|
-
if (activeHeaderAnchor) {
|
|
47
|
-
let index = 0;
|
|
48
|
-
let itemHighlighted = false; // @ts-expect-error: Must be <a> tags.
|
|
49
|
-
|
|
50
|
-
const links = document.getElementsByClassName(linkClassName);
|
|
51
|
-
|
|
52
|
-
while (index < links.length && !itemHighlighted) {
|
|
53
|
-
const link = links[index];
|
|
54
|
-
const {href} = link;
|
|
55
|
-
const anchorValue = decodeURIComponent(
|
|
56
|
-
href.substring(href.indexOf('#') + 1),
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
if (activeHeaderAnchor.id === anchorValue) {
|
|
60
|
-
if (lastActiveLink) {
|
|
61
|
-
lastActiveLink.classList.remove(linkActiveClassName);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
link.classList.add(linkActiveClassName);
|
|
65
|
-
setLastActiveLink(link);
|
|
66
|
-
itemHighlighted = true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
index += 1;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
document.addEventListener('scroll', setActiveLink);
|
|
75
|
-
document.addEventListener('resize', setActiveLink);
|
|
76
|
-
setActiveLink();
|
|
77
|
-
return () => {
|
|
78
|
-
document.removeEventListener('scroll', setActiveLink);
|
|
79
|
-
document.removeEventListener('resize', setActiveLink);
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export default useTOCHighlight;
|
package/lib-next/translations.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
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 {keyBy, chain, flatten} from 'lodash';
|
|
8
|
-
import {mergeTranslations} from '@docusaurus/utils';
|
|
9
|
-
|
|
10
|
-
function getNavbarTranslationFile(navbar) {
|
|
11
|
-
// TODO handle properly all the navbar item types here!
|
|
12
|
-
function flattenNavbarItems(items) {
|
|
13
|
-
const subItems = flatten(
|
|
14
|
-
items.map((item) => {
|
|
15
|
-
const allSubItems = flatten([item.items ?? []]);
|
|
16
|
-
return flattenNavbarItems(allSubItems);
|
|
17
|
-
}),
|
|
18
|
-
);
|
|
19
|
-
return [...items, ...subItems];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const allNavbarItems = flattenNavbarItems(navbar.items);
|
|
23
|
-
const navbarItemsTranslations = chain(
|
|
24
|
-
allNavbarItems.filter((navbarItem) => !!navbarItem.label),
|
|
25
|
-
)
|
|
26
|
-
.keyBy((navbarItem) => `item.label.${navbarItem.label}`)
|
|
27
|
-
.mapValues((navbarItem) => ({
|
|
28
|
-
message: navbarItem.label,
|
|
29
|
-
description: `Navbar item with label ${navbarItem.label}`,
|
|
30
|
-
}))
|
|
31
|
-
.value();
|
|
32
|
-
const titleTranslations = navbar.title
|
|
33
|
-
? {
|
|
34
|
-
title: {
|
|
35
|
-
message: navbar.title,
|
|
36
|
-
description: 'The title in the navbar',
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
: {};
|
|
40
|
-
return mergeTranslations([titleTranslations, navbarItemsTranslations]);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function translateNavbar(navbar, navbarTranslations) {
|
|
44
|
-
return {
|
|
45
|
-
...navbar,
|
|
46
|
-
title: navbarTranslations.title?.message ?? navbar.title,
|
|
47
|
-
// TODO handle properly all the navbar item types here!
|
|
48
|
-
items: navbar.items.map((item) => {
|
|
49
|
-
const subItems = item.items?.map((subItem) => ({
|
|
50
|
-
...subItem,
|
|
51
|
-
label:
|
|
52
|
-
navbarTranslations[`item.label.${subItem.label}`]?.message ??
|
|
53
|
-
subItem.label,
|
|
54
|
-
}));
|
|
55
|
-
return {
|
|
56
|
-
...item,
|
|
57
|
-
label:
|
|
58
|
-
navbarTranslations[`item.label.${item.label}`]?.message ?? item.label,
|
|
59
|
-
...(subItems
|
|
60
|
-
? {
|
|
61
|
-
items: subItems,
|
|
62
|
-
}
|
|
63
|
-
: undefined),
|
|
64
|
-
};
|
|
65
|
-
}),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function getFooterTranslationFile(footer) {
|
|
70
|
-
// TODO POC code
|
|
71
|
-
const footerLinkTitles = chain(footer.links.filter((link) => !!link.title))
|
|
72
|
-
.keyBy((link) => `link.title.${link.title}`)
|
|
73
|
-
.mapValues((link) => ({
|
|
74
|
-
message: link.title,
|
|
75
|
-
description: `The title of the footer links column with title=${link.title} in the footer`,
|
|
76
|
-
}))
|
|
77
|
-
.value();
|
|
78
|
-
const footerLinkLabels = chain(
|
|
79
|
-
flatten(footer.links.map((link) => link.items)).filter(
|
|
80
|
-
(link) => !!link.label,
|
|
81
|
-
),
|
|
82
|
-
)
|
|
83
|
-
.keyBy((linkItem) => `link.item.label.${linkItem.label}`)
|
|
84
|
-
.mapValues((linkItem) => ({
|
|
85
|
-
message: linkItem.label,
|
|
86
|
-
description: `The label of footer link with label=${
|
|
87
|
-
linkItem.label
|
|
88
|
-
} linking to ${linkItem.to ?? linkItem.href}`,
|
|
89
|
-
}))
|
|
90
|
-
.value();
|
|
91
|
-
const copyright = footer.copyright
|
|
92
|
-
? {
|
|
93
|
-
copyright: {
|
|
94
|
-
message: footer.copyright,
|
|
95
|
-
description: 'The footer copyright',
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
: {};
|
|
99
|
-
return mergeTranslations([footerLinkTitles, footerLinkLabels, copyright]);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function translateFooter(footer, footerTranslations) {
|
|
103
|
-
const links = footer.links.map((link) => ({
|
|
104
|
-
...link,
|
|
105
|
-
title:
|
|
106
|
-
footerTranslations[`link.title.${link.title}`]?.message ?? link.title,
|
|
107
|
-
items: link.items.map((linkItem) => ({
|
|
108
|
-
...linkItem,
|
|
109
|
-
label:
|
|
110
|
-
footerTranslations[`link.item.label.${linkItem.label}`]?.message ??
|
|
111
|
-
linkItem.label,
|
|
112
|
-
})),
|
|
113
|
-
}));
|
|
114
|
-
const copyright = footerTranslations.copyright?.message ?? footer.copyright;
|
|
115
|
-
return {...footer, links, copyright};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function getTranslationFiles({themeConfig}) {
|
|
119
|
-
const translationFiles = [
|
|
120
|
-
{
|
|
121
|
-
path: 'navbar',
|
|
122
|
-
content: getNavbarTranslationFile(themeConfig.navbar),
|
|
123
|
-
},
|
|
124
|
-
themeConfig.footer
|
|
125
|
-
? {
|
|
126
|
-
path: 'footer',
|
|
127
|
-
content: getFooterTranslationFile(themeConfig.footer),
|
|
128
|
-
}
|
|
129
|
-
: undefined,
|
|
130
|
-
];
|
|
131
|
-
return translationFiles.filter(Boolean);
|
|
132
|
-
}
|
|
133
|
-
export function translateThemeConfig({themeConfig, translationFiles}) {
|
|
134
|
-
const translationFilesMap = keyBy(translationFiles, (f) => f.path);
|
|
135
|
-
return {
|
|
136
|
-
...themeConfig,
|
|
137
|
-
navbar: translateNavbar(
|
|
138
|
-
themeConfig.navbar,
|
|
139
|
-
translationFilesMap.navbar.content,
|
|
140
|
-
),
|
|
141
|
-
footer: themeConfig.footer
|
|
142
|
-
? translateFooter(themeConfig.footer, translationFilesMap.footer.content)
|
|
143
|
-
: undefined,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
@@ -1,317 +0,0 @@
|
|
|
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
|
-
const {Joi, URISchema} = require('@docusaurus/utils-validation');
|
|
9
|
-
|
|
10
|
-
const DEFAULT_DOCS_CONFIG = {
|
|
11
|
-
versionPersistence: 'localStorage',
|
|
12
|
-
};
|
|
13
|
-
const DocsSchema = Joi.object({
|
|
14
|
-
versionPersistence: Joi.string()
|
|
15
|
-
.equal('localStorage', 'none')
|
|
16
|
-
.default(DEFAULT_DOCS_CONFIG.versionPersistence),
|
|
17
|
-
}).default(DEFAULT_DOCS_CONFIG);
|
|
18
|
-
|
|
19
|
-
const DEFAULT_COLOR_MODE_CONFIG = {
|
|
20
|
-
defaultMode: 'light',
|
|
21
|
-
disableSwitch: false,
|
|
22
|
-
respectPrefersColorScheme: false,
|
|
23
|
-
switchConfig: {
|
|
24
|
-
darkIcon: '🌜',
|
|
25
|
-
darkIconStyle: {},
|
|
26
|
-
lightIcon: '🌞',
|
|
27
|
-
lightIconStyle: {},
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const DEFAULT_CONFIG = {
|
|
32
|
-
colorMode: DEFAULT_COLOR_MODE_CONFIG,
|
|
33
|
-
docs: DEFAULT_DOCS_CONFIG,
|
|
34
|
-
metadatas: [],
|
|
35
|
-
prism: {
|
|
36
|
-
additionalLanguages: [],
|
|
37
|
-
},
|
|
38
|
-
navbar: {
|
|
39
|
-
hideOnScroll: false,
|
|
40
|
-
items: [],
|
|
41
|
-
},
|
|
42
|
-
hideableSidebar: false,
|
|
43
|
-
};
|
|
44
|
-
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
45
|
-
|
|
46
|
-
const NavbarItemPosition = Joi.string().equal('left', 'right').default('left');
|
|
47
|
-
|
|
48
|
-
const BaseNavbarItemSchema = Joi.object({
|
|
49
|
-
to: Joi.string(),
|
|
50
|
-
href: URISchema,
|
|
51
|
-
label: Joi.string(),
|
|
52
|
-
className: Joi.string(),
|
|
53
|
-
prependBaseUrlToHref: Joi.bool(),
|
|
54
|
-
})
|
|
55
|
-
// We allow any unknown attributes on the links
|
|
56
|
-
// (users may need additional attributes like target, aria-role, data-customAttribute...)
|
|
57
|
-
.unknown();
|
|
58
|
-
|
|
59
|
-
// TODO we should probably create a custom navbar item type "dropdown"
|
|
60
|
-
// having this recursive structure is bad because we only support 2 levels
|
|
61
|
-
// + parent/child don't have exactly the same props
|
|
62
|
-
const DefaultNavbarItemSchema = BaseNavbarItemSchema.append({
|
|
63
|
-
items: Joi.array().optional().items(BaseNavbarItemSchema),
|
|
64
|
-
position: NavbarItemPosition,
|
|
65
|
-
activeBasePath: Joi.string(),
|
|
66
|
-
activeBaseRegex: Joi.string(),
|
|
67
|
-
});
|
|
68
|
-
// TODO the dropdown parent item can have no href/to
|
|
69
|
-
// should check should not apply to dropdown parent item
|
|
70
|
-
// .xor('href', 'to');
|
|
71
|
-
|
|
72
|
-
const DocsVersionNavbarItemSchema = Joi.object({
|
|
73
|
-
type: Joi.string().equal('docsVersion').required(),
|
|
74
|
-
position: NavbarItemPosition,
|
|
75
|
-
label: Joi.string(),
|
|
76
|
-
to: Joi.string(),
|
|
77
|
-
docsPluginId: Joi.string(),
|
|
78
|
-
className: Joi.string(),
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const DocsVersionDropdownNavbarItemSchema = Joi.object({
|
|
82
|
-
type: Joi.string().equal('docsVersionDropdown').required(),
|
|
83
|
-
position: NavbarItemPosition,
|
|
84
|
-
docsPluginId: Joi.string(),
|
|
85
|
-
dropdownActiveClassDisabled: Joi.boolean(),
|
|
86
|
-
dropdownItemsBefore: Joi.array().items(BaseNavbarItemSchema).default([]),
|
|
87
|
-
dropdownItemsAfter: Joi.array().items(BaseNavbarItemSchema).default([]),
|
|
88
|
-
className: Joi.string(),
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const DocItemSchema = Joi.object({
|
|
92
|
-
type: Joi.string().equal('doc').required(),
|
|
93
|
-
position: NavbarItemPosition,
|
|
94
|
-
docId: Joi.string().required(),
|
|
95
|
-
label: Joi.string(),
|
|
96
|
-
docsPluginId: Joi.string(),
|
|
97
|
-
activeSidebarClassName: Joi.string().default('navbar__link--active'),
|
|
98
|
-
className: Joi.string(),
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const LocaleDropdownNavbarItemSchema = Joi.object({
|
|
102
|
-
type: Joi.string().equal('localeDropdown').required(),
|
|
103
|
-
position: NavbarItemPosition,
|
|
104
|
-
dropdownItemsBefore: Joi.array().items(BaseNavbarItemSchema).default([]),
|
|
105
|
-
dropdownItemsAfter: Joi.array().items(BaseNavbarItemSchema).default([]),
|
|
106
|
-
className: Joi.string(),
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const SearchItemSchema = Joi.object({
|
|
110
|
-
type: Joi.string().equal('search').required(),
|
|
111
|
-
position: NavbarItemPosition,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// Can this be made easier? :/
|
|
115
|
-
const isOfType = (type) => {
|
|
116
|
-
let typeSchema = Joi.string().required();
|
|
117
|
-
// because equal(undefined) is not supported :/
|
|
118
|
-
if (type) {
|
|
119
|
-
typeSchema = typeSchema.equal(type);
|
|
120
|
-
}
|
|
121
|
-
return Joi.object({
|
|
122
|
-
type: typeSchema,
|
|
123
|
-
})
|
|
124
|
-
.unknown()
|
|
125
|
-
.required();
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const NavbarItemSchema = Joi.object().when({
|
|
129
|
-
switch: [
|
|
130
|
-
{
|
|
131
|
-
is: isOfType('docsVersion'),
|
|
132
|
-
then: DocsVersionNavbarItemSchema,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
is: isOfType('docsVersionDropdown'),
|
|
136
|
-
then: DocsVersionDropdownNavbarItemSchema,
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
is: isOfType('doc'),
|
|
140
|
-
then: DocItemSchema,
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
is: isOfType('localeDropdown'),
|
|
144
|
-
then: LocaleDropdownNavbarItemSchema,
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
is: isOfType('search'),
|
|
148
|
-
then: SearchItemSchema,
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
is: isOfType(undefined),
|
|
152
|
-
then: Joi.forbidden().messages({
|
|
153
|
-
'any.unknown': 'Bad navbar item type {.type}',
|
|
154
|
-
}),
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
otherwise: DefaultNavbarItemSchema,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
/*
|
|
161
|
-
const NavbarItemSchema = Joi.object({
|
|
162
|
-
type: Joi.string().only(['docsVersion'])
|
|
163
|
-
})
|
|
164
|
-
.when(Joi.object({ type: 'docsVersion' }).unknown(), {
|
|
165
|
-
then: Joi.object({ pepperoni: Joi.boolean() })
|
|
166
|
-
})
|
|
167
|
-
.when(Joi.object().unknown(), {
|
|
168
|
-
then: Joi.object({ croutons: Joi.boolean() })
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
*/
|
|
172
|
-
|
|
173
|
-
/*
|
|
174
|
-
const NavbarItemSchema = Joi.object().when('type', {
|
|
175
|
-
is: Joi.valid('docsVersion'),
|
|
176
|
-
then: DocsVersionNavbarItemSchema,
|
|
177
|
-
otherwise: DefaultNavbarItemSchema,
|
|
178
|
-
});
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
const ColorModeSchema = Joi.object({
|
|
182
|
-
defaultMode: Joi.string()
|
|
183
|
-
.equal('dark', 'light')
|
|
184
|
-
.default(DEFAULT_COLOR_MODE_CONFIG.defaultMode),
|
|
185
|
-
disableSwitch: Joi.bool().default(DEFAULT_COLOR_MODE_CONFIG.disableSwitch),
|
|
186
|
-
respectPrefersColorScheme: Joi.bool().default(
|
|
187
|
-
DEFAULT_COLOR_MODE_CONFIG.respectPrefersColorScheme,
|
|
188
|
-
),
|
|
189
|
-
switchConfig: Joi.object({
|
|
190
|
-
darkIcon: Joi.string().default(
|
|
191
|
-
DEFAULT_COLOR_MODE_CONFIG.switchConfig.darkIcon,
|
|
192
|
-
),
|
|
193
|
-
darkIconStyle: Joi.object().default(
|
|
194
|
-
DEFAULT_COLOR_MODE_CONFIG.switchConfig.darkIconStyle,
|
|
195
|
-
),
|
|
196
|
-
lightIcon: Joi.string().default(
|
|
197
|
-
DEFAULT_COLOR_MODE_CONFIG.switchConfig.lightIcon,
|
|
198
|
-
),
|
|
199
|
-
lightIconStyle: Joi.object().default(
|
|
200
|
-
DEFAULT_COLOR_MODE_CONFIG.switchConfig.lightIconStyle,
|
|
201
|
-
),
|
|
202
|
-
}).default(DEFAULT_COLOR_MODE_CONFIG.switchConfig),
|
|
203
|
-
}).default(DEFAULT_COLOR_MODE_CONFIG);
|
|
204
|
-
|
|
205
|
-
// schema can probably be improved
|
|
206
|
-
const HtmlMetadataSchema = Joi.object({
|
|
207
|
-
id: Joi.string(),
|
|
208
|
-
name: Joi.string(),
|
|
209
|
-
property: Joi.string(),
|
|
210
|
-
content: Joi.string(),
|
|
211
|
-
itemprop: Joi.string(),
|
|
212
|
-
}).unknown();
|
|
213
|
-
|
|
214
|
-
const FooterLinkItemSchema = Joi.object({
|
|
215
|
-
to: Joi.string(),
|
|
216
|
-
href: URISchema,
|
|
217
|
-
html: Joi.string(),
|
|
218
|
-
label: Joi.string(),
|
|
219
|
-
})
|
|
220
|
-
.xor('to', 'href', 'html')
|
|
221
|
-
.with('to', 'label')
|
|
222
|
-
.with('href', 'label')
|
|
223
|
-
.nand('html', 'label')
|
|
224
|
-
// We allow any unknown attributes on the links
|
|
225
|
-
// (users may need additional attributes like target, aria-role, data-customAttribute...)
|
|
226
|
-
.unknown();
|
|
227
|
-
|
|
228
|
-
const CustomCssSchema = Joi.alternatives()
|
|
229
|
-
.try(Joi.array().items(Joi.string().required()), Joi.string().required())
|
|
230
|
-
.optional();
|
|
231
|
-
|
|
232
|
-
const ThemeConfigSchema = Joi.object({
|
|
233
|
-
// TODO temporary (@alpha-58)
|
|
234
|
-
disableDarkMode: Joi.any().forbidden(false).messages({
|
|
235
|
-
'any.unknown':
|
|
236
|
-
'disableDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.disableSwitch = true',
|
|
237
|
-
}),
|
|
238
|
-
// TODO temporary (@alpha-58)
|
|
239
|
-
defaultDarkMode: Joi.any().forbidden(false).messages({
|
|
240
|
-
'any.unknown':
|
|
241
|
-
'defaultDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.defaultMode = "dark"',
|
|
242
|
-
}),
|
|
243
|
-
customCss: CustomCssSchema,
|
|
244
|
-
colorMode: ColorModeSchema,
|
|
245
|
-
image: Joi.string(),
|
|
246
|
-
docs: DocsSchema,
|
|
247
|
-
metadatas: Joi.array()
|
|
248
|
-
.items(HtmlMetadataSchema)
|
|
249
|
-
.default(DEFAULT_CONFIG.metadatas),
|
|
250
|
-
announcementBar: Joi.object({
|
|
251
|
-
id: Joi.string().default('announcement-bar'),
|
|
252
|
-
content: Joi.string(),
|
|
253
|
-
backgroundColor: Joi.string(),
|
|
254
|
-
textColor: Joi.string(),
|
|
255
|
-
isCloseable: Joi.bool().default(true),
|
|
256
|
-
}).optional(),
|
|
257
|
-
navbar: Joi.object({
|
|
258
|
-
style: Joi.string().equal('dark', 'primary'),
|
|
259
|
-
hideOnScroll: Joi.bool().default(DEFAULT_CONFIG.navbar.hideOnScroll),
|
|
260
|
-
// TODO temporary (@alpha-58)
|
|
261
|
-
links: Joi.any().forbidden().messages({
|
|
262
|
-
'any.unknown':
|
|
263
|
-
'themeConfig.navbar.links has been renamed as themeConfig.navbar.items',
|
|
264
|
-
}),
|
|
265
|
-
items: Joi.array()
|
|
266
|
-
.items(NavbarItemSchema)
|
|
267
|
-
.default(DEFAULT_CONFIG.navbar.items),
|
|
268
|
-
title: Joi.string().allow('', null),
|
|
269
|
-
logo: Joi.object({
|
|
270
|
-
alt: Joi.string().allow(''),
|
|
271
|
-
src: Joi.string().required(),
|
|
272
|
-
srcDark: Joi.string(),
|
|
273
|
-
href: Joi.string(),
|
|
274
|
-
target: Joi.string(),
|
|
275
|
-
}),
|
|
276
|
-
}).default(DEFAULT_CONFIG.navbar),
|
|
277
|
-
footer: Joi.object({
|
|
278
|
-
style: Joi.string().equal('dark', 'light').default('light'),
|
|
279
|
-
logo: Joi.object({
|
|
280
|
-
alt: Joi.string().allow(''),
|
|
281
|
-
src: Joi.string(),
|
|
282
|
-
srcDark: Joi.string(),
|
|
283
|
-
href: Joi.string(),
|
|
284
|
-
}),
|
|
285
|
-
copyright: Joi.string(),
|
|
286
|
-
links: Joi.array()
|
|
287
|
-
.items(
|
|
288
|
-
Joi.object({
|
|
289
|
-
title: Joi.string().allow(null),
|
|
290
|
-
items: Joi.array().items(FooterLinkItemSchema).default([]),
|
|
291
|
-
}),
|
|
292
|
-
)
|
|
293
|
-
.default([]),
|
|
294
|
-
}).optional(),
|
|
295
|
-
prism: Joi.object({
|
|
296
|
-
theme: Joi.object({
|
|
297
|
-
plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
|
|
298
|
-
styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
|
|
299
|
-
}),
|
|
300
|
-
darkTheme: Joi.object({
|
|
301
|
-
plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
|
|
302
|
-
styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
|
|
303
|
-
}),
|
|
304
|
-
defaultLanguage: Joi.string(),
|
|
305
|
-
additionalLanguages: Joi.array()
|
|
306
|
-
.items(Joi.string())
|
|
307
|
-
.default(DEFAULT_CONFIG.prism.additionalLanguages),
|
|
308
|
-
})
|
|
309
|
-
.default(DEFAULT_CONFIG.prism)
|
|
310
|
-
.unknown(),
|
|
311
|
-
hideableSidebar: Joi.bool().default(DEFAULT_CONFIG.hideableSidebar),
|
|
312
|
-
});
|
|
313
|
-
exports.ThemeConfigSchema = ThemeConfigSchema;
|
|
314
|
-
|
|
315
|
-
exports.validateThemeConfig = ({validate, themeConfig}) => {
|
|
316
|
-
return validate(ThemeConfigSchema, themeConfig);
|
|
317
|
-
};
|