@docusaurus/theme-classic 2.0.0-beta.18 → 2.0.0-beta.19
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/admonitions.css +4 -0
- package/lib/default.css +3038 -0
- package/lib/getSwizzleConfig.js +9 -2
- package/lib/index.js +4 -4
- package/lib/nprogress.css +41 -0
- package/lib/nprogress.js +46 -0
- package/lib/theme-classic.d.ts +315 -33
- package/lib/validateThemeConfig.js +72 -14
- package/lib-next/theme/BackToTopButton/index.js +6 -102
- package/lib-next/theme/BlogLayout/index.js +1 -5
- package/lib-next/theme/BlogListPaginator/index.js +25 -28
- package/lib-next/theme/BlogPostAuthor/index.js +3 -6
- package/lib-next/theme/BlogPostItem/styles.module.css +9 -0
- package/lib-next/theme/BlogPostPaginator/index.js +25 -28
- package/lib-next/theme/BlogSidebar/Desktop/index.js +41 -0
- package/lib-next/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
- package/lib-next/theme/BlogSidebar/Mobile/index.js +36 -0
- package/lib-next/theme/BlogSidebar/index.js +11 -31
- package/lib-next/theme/BlogTagsListPage/index.js +2 -3
- package/lib-next/theme/BlogTagsPostsPage/index.js +4 -6
- package/lib-next/theme/CodeBlock/Container/index.js +29 -0
- package/lib-next/theme/CodeBlock/Container/styles.module.css +14 -0
- package/lib-next/theme/CodeBlock/Content/Element.js +23 -0
- package/lib-next/theme/CodeBlock/Content/String.js +104 -0
- package/{src/theme/CodeBlock → lib-next/theme/CodeBlock/Content}/styles.module.css +39 -9
- package/lib-next/theme/CodeBlock/CopyButton/index.js +3 -2
- package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +0 -19
- package/lib-next/theme/CodeBlock/Line/index.js +49 -0
- package/lib-next/theme/CodeBlock/Line/styles.module.css +51 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/index.js +40 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/lib-next/theme/CodeBlock/index.js +27 -133
- package/lib-next/theme/Details/index.js +1 -1
- package/lib-next/theme/DocBreadcrumbs/index.js +50 -23
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +8 -0
- package/lib-next/theme/DocCardList/index.js +6 -4
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +3 -3
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/lib-next/theme/DocItem/index.js +1 -1
- package/lib-next/theme/DocItem/styles.module.css +6 -0
- package/lib-next/theme/DocPage/Layout/Main/index.js +29 -0
- package/lib-next/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +34 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/index.js +68 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
- package/lib-next/theme/DocPage/Layout/index.js +34 -0
- package/lib-next/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
- package/lib-next/theme/DocPage/index.js +28 -146
- package/lib-next/theme/DocPaginator/index.js +25 -28
- package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
- package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
- package/lib-next/theme/DocSidebar/Desktop/index.js +4 -2
- package/lib-next/theme/DocSidebarItem/Category.js +197 -0
- package/lib-next/theme/DocSidebarItem/Html.js +27 -0
- package/{src/theme/DocSidebarItem/styles.module.css → lib-next/theme/DocSidebarItem/Html.module.css} +0 -4
- package/lib-next/theme/DocSidebarItem/Link.js +53 -0
- package/{src/theme/MDXComponents/Ul.module.css → lib-next/theme/DocSidebarItem/Link.module.css} +2 -3
- package/lib-next/theme/DocSidebarItem/index.js +4 -246
- package/lib-next/theme/DocSidebarItems/index.js +1 -6
- package/lib-next/theme/DocTagDocListPage/index.js +3 -3
- package/lib-next/theme/DocVersionBanner/index.js +2 -2
- package/lib-next/theme/Footer/Links/MultiColumn/index.js +1 -1
- package/lib-next/theme/Heading/index.js +4 -20
- package/lib-next/theme/IconHome/index.js +17 -0
- package/lib-next/theme/LastUpdated/index.js +1 -0
- package/lib-next/theme/Layout/index.js +1 -1
- package/lib-next/theme/MDXComponents/Ul.js +2 -4
- package/lib-next/theme/Navbar/Content/index.js +6 -1
- package/lib-next/theme/Navbar/Logo/index.js +1 -1
- package/lib-next/theme/Navbar/Search/index.js +11 -0
- package/lib-next/theme/Navbar/Search/styles.module.css +20 -0
- package/lib-next/theme/NavbarItem/ComponentTypes.js +27 -0
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +11 -28
- package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +10 -42
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +25 -29
- package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +2 -9
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +4 -1
- package/lib-next/theme/NavbarItem/HtmlNavbarItem.js +30 -0
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +5 -10
- package/lib-next/theme/NavbarItem/NavbarNavLink.js +49 -31
- package/lib-next/theme/NavbarItem/SearchNavbarItem.js +6 -1
- package/lib-next/theme/NavbarItem/index.js +4 -23
- package/lib-next/theme/NavbarItem/utils.js +2 -1
- package/lib-next/theme/PaginatorNavLink/index.js +8 -2
- package/lib-next/theme/SiteMetadata/index.js +8 -7
- package/lib-next/theme/SkipToContent/index.js +3 -29
- package/lib-next/theme/TOCCollapsible/CollapseButton.js +29 -0
- package/{src/theme/TOCCollapsible/styles.module.css → lib-next/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
- package/lib-next/theme/TOCCollapsible/index.js +3 -13
- package/lib-next/theme/TOCCollapsible/index.module.css +31 -0
- package/lib-next/theme/TOCItems/Tree.js +40 -0
- package/lib-next/theme/TOCItems/index.js +3 -34
- package/lib-next/theme/TabItem/index.js +3 -1
- package/lib-next/theme/{MDXComponents/Ul.module.css → TabItem/styles.module.css} +2 -3
- package/lib-next/theme/Tabs/__tests__/index.test.js +3 -3
- package/lib-next/theme/Tabs/index.js +3 -3
- package/lib-next/theme/Tabs/styles.module.css +4 -0
- package/lib-next/theme/Tag/index.js +2 -3
- package/lib-next/theme/TagsListInline/index.js +1 -1
- package/package.json +23 -18
- package/src/admonitions.css +4 -0
- package/src/getSwizzleConfig.ts +10 -2
- package/src/index.ts +4 -3
- package/src/nprogress.css +41 -0
- package/src/nprogress.ts +31 -0
- package/src/theme/BackToTopButton/index.tsx +5 -112
- package/src/theme/BlogLayout/index.tsx +1 -5
- package/src/theme/BlogListPaginator/index.tsx +25 -28
- package/src/theme/BlogPostAuthor/index.tsx +3 -7
- package/src/theme/BlogPostItem/styles.module.css +9 -0
- package/src/theme/BlogPostPaginator/index.tsx +25 -28
- package/src/theme/BlogSidebar/Desktop/index.tsx +45 -0
- package/src/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
- package/src/theme/BlogSidebar/Mobile/index.tsx +38 -0
- package/src/theme/BlogSidebar/index.tsx +10 -31
- package/src/theme/BlogTagsListPage/index.tsx +2 -3
- package/src/theme/BlogTagsPostsPage/index.tsx +8 -5
- package/src/theme/CodeBlock/Container/index.tsx +35 -0
- package/src/theme/CodeBlock/Container/styles.module.css +14 -0
- package/src/theme/CodeBlock/Content/Element.tsx +30 -0
- package/src/theme/CodeBlock/Content/String.tsx +111 -0
- package/{lib-next/theme/CodeBlock → src/theme/CodeBlock/Content}/styles.module.css +39 -9
- package/src/theme/CodeBlock/CopyButton/index.tsx +3 -2
- package/src/theme/CodeBlock/CopyButton/styles.module.css +0 -19
- package/src/theme/CodeBlock/Line/index.tsx +48 -0
- package/src/theme/CodeBlock/Line/styles.module.css +51 -0
- package/src/theme/CodeBlock/WordWrapButton/index.tsx +49 -0
- package/src/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/src/theme/CodeBlock/index.tsx +29 -133
- package/src/theme/Details/index.tsx +1 -1
- package/src/theme/DocBreadcrumbs/index.tsx +50 -20
- package/src/theme/DocBreadcrumbs/styles.module.css +8 -0
- package/src/theme/DocCardList/index.tsx +5 -7
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/src/theme/DocItem/index.tsx +1 -1
- package/src/theme/DocItem/styles.module.css +6 -0
- package/src/theme/DocPage/Layout/Main/index.tsx +37 -0
- package/src/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +40 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/src/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
- package/src/theme/DocPage/Layout/Sidebar/index.tsx +74 -0
- package/src/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
- package/src/theme/DocPage/Layout/index.tsx +39 -0
- package/src/theme/DocPage/index.tsx +28 -157
- package/src/theme/DocPaginator/index.tsx +25 -28
- package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
- package/src/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
- package/src/theme/DocSidebar/Desktop/index.tsx +4 -2
- package/src/theme/DocSidebarItem/Category.tsx +210 -0
- package/{lib-next/theme/DocSidebarItem/styles.module.css → src/theme/DocSidebarItem/Html.module.css} +0 -4
- package/src/theme/DocSidebarItem/Html.tsx +34 -0
- package/src/theme/DocSidebarItem/Link.module.css +10 -0
- package/src/theme/DocSidebarItem/Link.tsx +58 -0
- package/src/theme/DocSidebarItem/index.tsx +4 -259
- package/src/theme/DocSidebarItems/index.tsx +1 -6
- package/src/theme/DocTagDocListPage/index.tsx +3 -4
- package/src/theme/DocVersionBanner/index.tsx +2 -2
- package/src/theme/Footer/Links/MultiColumn/index.tsx +1 -1
- package/src/theme/Heading/index.tsx +4 -18
- package/src/theme/IconHome/index.tsx +20 -0
- package/src/theme/LastUpdated/index.tsx +1 -0
- package/src/theme/Layout/index.tsx +1 -1
- package/src/theme/MDXComponents/Details.tsx +2 -3
- package/src/theme/MDXComponents/Ul.tsx +2 -6
- package/src/theme/Navbar/Content/index.tsx +6 -1
- package/src/theme/Navbar/Logo/index.tsx +1 -1
- package/src/theme/Navbar/Search/index.tsx +15 -0
- package/src/theme/Navbar/Search/styles.module.css +20 -0
- package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
- package/src/theme/NavbarItem/DocNavbarItem.tsx +13 -32
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +9 -49
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +26 -33
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +3 -10
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -1
- package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -9
- package/src/theme/NavbarItem/NavbarNavLink.tsx +41 -25
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +6 -1
- package/src/theme/NavbarItem/index.tsx +9 -38
- package/src/theme/NavbarItem/utils.ts +5 -2
- package/src/theme/PaginatorNavLink/index.tsx +8 -2
- package/src/theme/SiteMetadata/index.tsx +8 -8
- package/src/theme/SkipToContent/index.tsx +3 -29
- package/{lib-next/theme/TOCCollapsible/styles.module.css → src/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
- package/src/theme/TOCCollapsible/CollapseButton.tsx +35 -0
- package/src/theme/TOCCollapsible/index.module.css +31 -0
- package/src/theme/TOCCollapsible/index.tsx +3 -14
- package/src/theme/TOCItems/Tree.tsx +46 -0
- package/src/theme/TOCItems/index.tsx +2 -41
- package/src/theme/TabItem/index.tsx +7 -1
- package/src/theme/TabItem/styles.module.css +10 -0
- package/src/theme/Tabs/index.tsx +3 -3
- package/src/theme/Tabs/styles.module.css +4 -0
- package/src/theme/Tag/index.tsx +2 -4
- package/src/theme/TagsListInline/index.tsx +1 -1
- package/src/theme-classic.d.ts +315 -33
- package/src/validateThemeConfig.ts +80 -13
- package/lib/types.d.ts +0 -11
- package/lib-next/theme/DocPage/styles.module.css +0 -82
- package/src/theme/DocPage/styles.module.css +0 -82
- package/src/types.d.ts +0 -11
|
@@ -7,48 +7,26 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
10
|
-
import {
|
|
11
|
-
useLatestVersion,
|
|
12
|
-
useActiveDocContext,
|
|
13
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
10
|
+
import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
|
|
14
11
|
import clsx from 'clsx';
|
|
15
12
|
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
16
13
|
import type {Props} from '@theme/NavbarItem/DocNavbarItem';
|
|
17
|
-
import {
|
|
18
|
-
import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
|
|
19
|
-
|
|
20
|
-
function getDocInVersions(versions: GlobalVersion[], docId: string) {
|
|
21
|
-
const allDocs = versions.flatMap((version) => version.docs);
|
|
22
|
-
const doc = allDocs.find((versionDoc) => versionDoc.id === docId);
|
|
23
|
-
if (!doc) {
|
|
24
|
-
const docIds = allDocs.map((versionDoc) => versionDoc.id).join('\n- ');
|
|
25
|
-
throw new Error(
|
|
26
|
-
`DocNavbarItem: couldn't find any doc with id "${docId}" in version${
|
|
27
|
-
versions.length ? 's' : ''
|
|
28
|
-
} ${versions.map((version) => version.name).join(', ')}".
|
|
29
|
-
Available doc ids are:\n- ${docIds}`,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
return doc;
|
|
33
|
-
}
|
|
14
|
+
import {useLayoutDoc} from '@docusaurus/theme-common';
|
|
34
15
|
|
|
35
16
|
export default function DocNavbarItem({
|
|
36
17
|
docId,
|
|
37
18
|
label: staticLabel,
|
|
38
19
|
docsPluginId,
|
|
39
20
|
...props
|
|
40
|
-
}: Props): JSX.Element {
|
|
41
|
-
const {
|
|
42
|
-
const
|
|
43
|
-
|
|
21
|
+
}: Props): JSX.Element | null {
|
|
22
|
+
const {activeDoc} = useActiveDocContext(docsPluginId);
|
|
23
|
+
const doc = useLayoutDoc(docId, docsPluginId);
|
|
24
|
+
|
|
25
|
+
// Draft items are not displayed in the navbar.
|
|
26
|
+
if (doc === null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
44
29
|
|
|
45
|
-
// Versions used to look for the doc to link to, ordered + no duplicate
|
|
46
|
-
const versions = uniq(
|
|
47
|
-
[activeVersion, preferredVersion, latestVersion].filter(
|
|
48
|
-
Boolean,
|
|
49
|
-
) as GlobalVersion[],
|
|
50
|
-
);
|
|
51
|
-
const doc = getDocInVersions(versions, docId);
|
|
52
30
|
const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
|
|
53
31
|
|
|
54
32
|
return (
|
|
@@ -57,6 +35,9 @@ export default function DocNavbarItem({
|
|
|
57
35
|
{...props}
|
|
58
36
|
className={clsx(props.className, {
|
|
59
37
|
[activeDocInfimaClassName]:
|
|
38
|
+
// Do not make the item active if the active doc doesn't have sidebar.
|
|
39
|
+
// If `activeDoc === doc` react-router will make it active anyways,
|
|
40
|
+
// regardless of the existence of a sidebar
|
|
60
41
|
activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar,
|
|
61
42
|
})}
|
|
62
43
|
activeClassName={activeDocInfimaClassName}
|
|
@@ -7,48 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
10
|
-
import {
|
|
11
|
-
useLatestVersion,
|
|
12
|
-
useActiveDocContext,
|
|
13
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
10
|
+
import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
|
|
14
11
|
import clsx from 'clsx';
|
|
15
12
|
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
16
|
-
import {
|
|
13
|
+
import {useLayoutDocsSidebar} from '@docusaurus/theme-common';
|
|
17
14
|
|
|
18
15
|
import type {Props} from '@theme/NavbarItem/DocSidebarNavbarItem';
|
|
19
|
-
import type {
|
|
20
|
-
GlobalVersion,
|
|
21
|
-
GlobalSidebar,
|
|
22
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
23
|
-
|
|
24
|
-
function getSidebarLink(versions: GlobalVersion[], sidebarId: string) {
|
|
25
|
-
const allSidebars = versions
|
|
26
|
-
.flatMap((version) => {
|
|
27
|
-
if (version.sidebars) {
|
|
28
|
-
return Object.entries(version.sidebars);
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
})
|
|
32
|
-
.filter(
|
|
33
|
-
(sidebarItem): sidebarItem is [string, GlobalSidebar] => !!sidebarItem,
|
|
34
|
-
);
|
|
35
|
-
const sidebarEntry = allSidebars.find((sidebar) => sidebar[0] === sidebarId);
|
|
36
|
-
if (!sidebarEntry) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
`DocSidebarNavbarItem: couldn't find any sidebar with id "${sidebarId}" in version${
|
|
39
|
-
versions.length ? 's' : ''
|
|
40
|
-
} ${versions.map((version) => version.name).join(', ')}".
|
|
41
|
-
Available sidebar ids are:
|
|
42
|
-
- ${Object.keys(allSidebars).join('\n- ')}`,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
if (!sidebarEntry[1].link) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
`DocSidebarNavbarItem: couldn't find any document for sidebar with id "${sidebarId}"`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
return sidebarEntry[1].link;
|
|
51
|
-
}
|
|
52
16
|
|
|
53
17
|
export default function DocSidebarNavbarItem({
|
|
54
18
|
sidebarId,
|
|
@@ -56,17 +20,13 @@ export default function DocSidebarNavbarItem({
|
|
|
56
20
|
docsPluginId,
|
|
57
21
|
...props
|
|
58
22
|
}: Props): JSX.Element {
|
|
59
|
-
const {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Boolean,
|
|
67
|
-
) as GlobalVersion[],
|
|
68
|
-
);
|
|
69
|
-
const sidebarLink = getSidebarLink(versions, sidebarId);
|
|
23
|
+
const {activeDoc} = useActiveDocContext(docsPluginId);
|
|
24
|
+
const sidebarLink = useLayoutDocsSidebar(sidebarId, docsPluginId).link;
|
|
25
|
+
if (!sidebarLink) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`DocSidebarNavbarItem: Sidebar with ID "${sidebarId}" doesn't have anything to be linked to.`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
70
30
|
const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
|
|
71
31
|
|
|
72
32
|
return (
|
|
@@ -10,14 +10,15 @@ import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
|
10
10
|
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
11
11
|
import {
|
|
12
12
|
useVersions,
|
|
13
|
-
useLatestVersion,
|
|
14
13
|
useActiveDocContext,
|
|
15
14
|
} from '@docusaurus/plugin-content-docs/client';
|
|
16
|
-
import
|
|
17
|
-
|
|
15
|
+
import {
|
|
16
|
+
useDocsPreferredVersion,
|
|
17
|
+
useDocsVersionCandidates,
|
|
18
|
+
} from '@docusaurus/theme-common';
|
|
18
19
|
import {translate} from '@docusaurus/Translate';
|
|
19
20
|
import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
|
|
20
|
-
import type {
|
|
21
|
+
import type {Props} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
|
21
22
|
|
|
22
23
|
const getVersionMainDoc = (version: GlobalVersion) =>
|
|
23
24
|
version.docs.find((doc) => doc.id === version.mainDocId)!;
|
|
@@ -32,36 +33,28 @@ export default function DocsVersionDropdownNavbarItem({
|
|
|
32
33
|
}: Props): JSX.Element {
|
|
33
34
|
const activeDocContext = useActiveDocContext(docsPluginId);
|
|
34
35
|
const versions = useVersions(docsPluginId);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return [...dropdownItemsBefore, ...versionLinks, ...dropdownItemsAfter];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const items = getItems();
|
|
36
|
+
const {savePreferredVersionName} = useDocsPreferredVersion(docsPluginId);
|
|
37
|
+
const versionLinks = versions.map((version) => {
|
|
38
|
+
// We try to link to the same doc, in another version
|
|
39
|
+
// When not possible, fallback to the "main doc" of the version
|
|
40
|
+
const versionDoc =
|
|
41
|
+
activeDocContext?.alternateDocVersions[version.name] ??
|
|
42
|
+
getVersionMainDoc(version);
|
|
43
|
+
return {
|
|
44
|
+
isNavLink: true,
|
|
45
|
+
label: version.label,
|
|
46
|
+
to: versionDoc.path,
|
|
47
|
+
isActive: () => version === activeDocContext?.activeVersion,
|
|
48
|
+
onClick: () => savePreferredVersionName(version.name),
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
const items = [
|
|
52
|
+
...dropdownItemsBefore,
|
|
53
|
+
...versionLinks,
|
|
54
|
+
...dropdownItemsAfter,
|
|
55
|
+
];
|
|
62
56
|
|
|
63
|
-
const dropdownVersion =
|
|
64
|
-
activeDocContext.activeVersion ?? preferredVersion ?? latestVersion;
|
|
57
|
+
const dropdownVersion = useDocsVersionCandidates(docsPluginId)[0];
|
|
65
58
|
|
|
66
59
|
// Mobile dropdown is handled a bit differently
|
|
67
60
|
const dropdownLabel =
|
|
@@ -7,13 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
useLatestVersion,
|
|
13
|
-
type GlobalVersion,
|
|
14
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
10
|
+
import {useDocsVersionCandidates} from '@docusaurus/theme-common';
|
|
11
|
+
import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
|
|
15
12
|
import type {Props} from '@theme/NavbarItem/DocsVersionNavbarItem';
|
|
16
|
-
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
17
13
|
|
|
18
14
|
const getVersionMainDoc = (version: GlobalVersion) =>
|
|
19
15
|
version.docs.find((doc) => doc.id === version.mainDocId)!;
|
|
@@ -24,10 +20,7 @@ export default function DocsVersionNavbarItem({
|
|
|
24
20
|
docsPluginId,
|
|
25
21
|
...props
|
|
26
22
|
}: Props): JSX.Element {
|
|
27
|
-
const
|
|
28
|
-
const {preferredVersion} = useDocsPreferredVersion(docsPluginId);
|
|
29
|
-
const latestVersion = useLatestVersion(docsPluginId);
|
|
30
|
-
const version = activeVersion ?? preferredVersion ?? latestVersion;
|
|
23
|
+
const version = useDocsVersionCandidates(docsPluginId)[0];
|
|
31
24
|
const label = staticLabel ?? version.label;
|
|
32
25
|
const path = staticTo ?? getVersionMainDoc(version).path;
|
|
33
26
|
return <DefaultNavbarItem {...props} label={label} to={path} />;
|
|
@@ -157,7 +157,10 @@ function DropdownNavbarItemMobile({
|
|
|
157
157
|
})}>
|
|
158
158
|
<NavbarNavLink
|
|
159
159
|
role="button"
|
|
160
|
-
className={clsx(
|
|
160
|
+
className={clsx(
|
|
161
|
+
'menu__link menu__link--sublist menu__link--sublist-caret',
|
|
162
|
+
className,
|
|
163
|
+
)}
|
|
161
164
|
{...props}
|
|
162
165
|
onClick={(e) => {
|
|
163
166
|
e.preventDefault();
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
import React from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
|
|
11
|
+
import type {Props} from '@theme/NavbarItem/HtmlNavbarItem';
|
|
12
|
+
|
|
13
|
+
export default function HtmlNavbarItem({
|
|
14
|
+
value,
|
|
15
|
+
className,
|
|
16
|
+
mobile = false,
|
|
17
|
+
isDropdownItem = false,
|
|
18
|
+
}: Props): JSX.Element {
|
|
19
|
+
const Comp = isDropdownItem ? 'li' : 'div';
|
|
20
|
+
return (
|
|
21
|
+
<Comp
|
|
22
|
+
className={clsx(
|
|
23
|
+
{
|
|
24
|
+
navbar__item: !mobile && !isDropdownItem,
|
|
25
|
+
'menu__list-item': mobile,
|
|
26
|
+
},
|
|
27
|
+
className,
|
|
28
|
+
)}
|
|
29
|
+
dangerouslySetInnerHTML={{__html: value}}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -27,10 +27,6 @@ export default function LocaleDropdownNavbarItem({
|
|
|
27
27
|
} = useDocusaurusContext();
|
|
28
28
|
const alternatePageUtils = useAlternatePageUtils();
|
|
29
29
|
|
|
30
|
-
function getLocaleLabel(locale: string) {
|
|
31
|
-
return localeConfigs[locale]!.label;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
30
|
const localeItems = locales.map((locale): LinkLikeNavbarItemProps => {
|
|
35
31
|
const to = `pathname://${alternatePageUtils.createUrl({
|
|
36
32
|
locale,
|
|
@@ -38,7 +34,7 @@ export default function LocaleDropdownNavbarItem({
|
|
|
38
34
|
})}`;
|
|
39
35
|
return {
|
|
40
36
|
isNavLink: true,
|
|
41
|
-
label:
|
|
37
|
+
label: localeConfigs[locale]!.label,
|
|
42
38
|
to,
|
|
43
39
|
target: '_self',
|
|
44
40
|
autoAddBaseUrl: false,
|
|
@@ -55,17 +51,17 @@ export default function LocaleDropdownNavbarItem({
|
|
|
55
51
|
id: 'theme.navbar.mobileLanguageDropdown.label',
|
|
56
52
|
description: 'The label for the mobile language switcher dropdown',
|
|
57
53
|
})
|
|
58
|
-
:
|
|
54
|
+
: localeConfigs[currentLocale]!.label;
|
|
59
55
|
|
|
60
56
|
return (
|
|
61
57
|
<DropdownNavbarItem
|
|
62
58
|
{...props}
|
|
63
59
|
mobile={mobile}
|
|
64
60
|
label={
|
|
65
|
-
|
|
61
|
+
<>
|
|
66
62
|
<IconLanguage className={styles.iconLanguage} />
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
{dropdownLabel}
|
|
64
|
+
</>
|
|
69
65
|
}
|
|
70
66
|
items={items}
|
|
71
67
|
/>
|
|
@@ -21,6 +21,7 @@ export default function NavbarNavLink({
|
|
|
21
21
|
to,
|
|
22
22
|
href,
|
|
23
23
|
label,
|
|
24
|
+
html,
|
|
24
25
|
activeClassName = '',
|
|
25
26
|
prependBaseUrlToHref,
|
|
26
27
|
...props
|
|
@@ -33,32 +34,47 @@ export default function NavbarNavLink({
|
|
|
33
34
|
const isExternalLink = label && href && !isInternalUrl(href);
|
|
34
35
|
const isDropdownLink = activeClassName === dropdownLinkActiveClass;
|
|
35
36
|
|
|
37
|
+
// Link content is set through html XOR label
|
|
38
|
+
const linkContentProps = html
|
|
39
|
+
? {dangerouslySetInnerHTML: {__html: html}}
|
|
40
|
+
: {
|
|
41
|
+
children: (
|
|
42
|
+
<>
|
|
43
|
+
{label}
|
|
44
|
+
{isExternalLink && (
|
|
45
|
+
<IconExternalLink
|
|
46
|
+
{...(isDropdownLink && {width: 12, height: 12})}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
</>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (href) {
|
|
54
|
+
return (
|
|
55
|
+
<Link
|
|
56
|
+
href={prependBaseUrlToHref ? normalizedHref : href}
|
|
57
|
+
{...props}
|
|
58
|
+
{...linkContentProps}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
36
63
|
return (
|
|
37
64
|
<Link
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
? isRegexpStringMatch(activeBaseRegex, location.pathname)
|
|
53
|
-
: location.pathname.startsWith(activeBaseUrl),
|
|
54
|
-
}
|
|
55
|
-
: null),
|
|
56
|
-
})}
|
|
57
|
-
{...props}>
|
|
58
|
-
{label}
|
|
59
|
-
{isExternalLink && (
|
|
60
|
-
<IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
|
|
61
|
-
)}
|
|
62
|
-
</Link>
|
|
65
|
+
to={toUrl}
|
|
66
|
+
isNavLink
|
|
67
|
+
activeClassName={
|
|
68
|
+
!props.className?.includes(activeClassName) ? activeClassName : ''
|
|
69
|
+
}
|
|
70
|
+
{...((activeBasePath || activeBaseRegex) && {
|
|
71
|
+
isActive: (_match, location) =>
|
|
72
|
+
activeBaseRegex
|
|
73
|
+
? isRegexpStringMatch(activeBaseRegex, location.pathname)
|
|
74
|
+
: location.pathname.startsWith(activeBaseUrl),
|
|
75
|
+
})}
|
|
76
|
+
{...props}
|
|
77
|
+
{...linkContentProps}
|
|
78
|
+
/>
|
|
63
79
|
);
|
|
64
80
|
}
|
|
@@ -8,11 +8,16 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import type {Props} from '@theme/NavbarItem/SearchNavbarItem';
|
|
10
10
|
import SearchBar from '@theme/SearchBar';
|
|
11
|
+
import NavbarSearch from '@theme/Navbar/Search';
|
|
11
12
|
|
|
12
13
|
export default function SearchNavbarItem({mobile}: Props): JSX.Element | null {
|
|
13
14
|
if (mobile) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
return
|
|
18
|
+
return (
|
|
19
|
+
<NavbarSearch>
|
|
20
|
+
<SearchBar />
|
|
21
|
+
</NavbarSearch>
|
|
22
|
+
);
|
|
18
23
|
}
|
|
@@ -6,55 +6,26 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import
|
|
10
|
-
import DropdownNavbarItem, {
|
|
11
|
-
type Props as DropdownNavbarItemProps,
|
|
12
|
-
} from '@theme/NavbarItem/DropdownNavbarItem';
|
|
13
|
-
import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
|
|
14
|
-
import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
|
|
9
|
+
import {type Props as DropdownNavbarItemProps} from '@theme/NavbarItem/DropdownNavbarItem';
|
|
15
10
|
import type {Types, Props} from '@theme/NavbarItem';
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
// Not really worth typing, as we pass all props down immediately
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
[type in Exclude<Types, undefined>]: () => (props: any) => JSX.Element;
|
|
21
|
-
} = {
|
|
22
|
-
default: () => DefaultNavbarItem,
|
|
23
|
-
localeDropdown: () => LocaleDropdownNavbarItem,
|
|
24
|
-
search: () => SearchNavbarItem,
|
|
25
|
-
dropdown: () => DropdownNavbarItem,
|
|
12
|
+
import ComponentTypes from '@theme/NavbarItem/ComponentTypes';
|
|
26
13
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
docsVersion: () => require('@theme/NavbarItem/DocsVersionNavbarItem').default,
|
|
31
|
-
docsVersionDropdown: () =>
|
|
32
|
-
require('@theme/NavbarItem/DocsVersionDropdownNavbarItem').default,
|
|
33
|
-
doc: () => require('@theme/NavbarItem/DocNavbarItem').default,
|
|
34
|
-
docSidebar: () => require('@theme/NavbarItem/DocSidebarNavbarItem').default,
|
|
35
|
-
/* eslint-enable @typescript-eslint/no-var-requires, global-require */
|
|
36
|
-
} as const;
|
|
37
|
-
|
|
38
|
-
type NavbarItemComponentType = keyof typeof NavbarItemComponents;
|
|
39
|
-
|
|
40
|
-
const getNavbarItemComponent = (type: NavbarItemComponentType) => {
|
|
41
|
-
const navbarItemComponentFn = NavbarItemComponents[type];
|
|
42
|
-
if (!navbarItemComponentFn) {
|
|
14
|
+
const getNavbarItemComponent = (type: NonNullable<Types>) => {
|
|
15
|
+
const component = ComponentTypes[type];
|
|
16
|
+
if (!component) {
|
|
43
17
|
throw new Error(`No NavbarItem component found for type "${type}".`);
|
|
44
18
|
}
|
|
45
|
-
return
|
|
19
|
+
return component;
|
|
46
20
|
};
|
|
47
21
|
|
|
48
|
-
function getComponentType(
|
|
49
|
-
type: Types,
|
|
50
|
-
isDropdown: boolean,
|
|
51
|
-
): NavbarItemComponentType {
|
|
22
|
+
function getComponentType(type: Types, isDropdown: boolean) {
|
|
52
23
|
// Backward compatibility: navbar item with no type set
|
|
53
24
|
// but containing dropdown items should use the type "dropdown"
|
|
54
25
|
if (!type || type === 'default') {
|
|
55
26
|
return isDropdown ? 'dropdown' : 'default';
|
|
56
27
|
}
|
|
57
|
-
return type as
|
|
28
|
+
return type as NonNullable<Types>;
|
|
58
29
|
}
|
|
59
30
|
|
|
60
31
|
export default function NavbarItem({type, ...props}: Props): JSX.Element {
|
|
@@ -63,5 +34,5 @@ export default function NavbarItem({type, ...props}: Props): JSX.Element {
|
|
|
63
34
|
(props as DropdownNavbarItemProps).items !== undefined,
|
|
64
35
|
);
|
|
65
36
|
const NavbarItemComponent = getNavbarItemComponent(componentType);
|
|
66
|
-
return <NavbarItemComponent {...props} />;
|
|
37
|
+
return <NavbarItemComponent {...(props as never)} />;
|
|
67
38
|
}
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/* eslint-disable import/no-named-export */
|
|
9
|
+
|
|
10
|
+
export const getInfimaActiveClassName = (
|
|
11
|
+
mobile?: boolean,
|
|
12
|
+
): `${'menu' | 'navbar'}__link--active` =>
|
|
10
13
|
mobile ? 'menu__link--active' : 'navbar__link--active';
|
|
@@ -6,13 +6,19 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
9
10
|
import Link from '@docusaurus/Link';
|
|
10
11
|
import type {Props} from '@theme/PaginatorNavLink';
|
|
11
12
|
|
|
12
13
|
export default function PaginatorNavLink(props: Props): JSX.Element {
|
|
13
|
-
const {permalink, title, subLabel} = props;
|
|
14
|
+
const {permalink, title, subLabel, isNext} = props;
|
|
14
15
|
return (
|
|
15
|
-
<Link
|
|
16
|
+
<Link
|
|
17
|
+
className={clsx(
|
|
18
|
+
'pagination-nav__link',
|
|
19
|
+
isNext ? 'pagination-nav__link--next' : 'pagination-nav__link--prev',
|
|
20
|
+
)}
|
|
21
|
+
to={permalink}>
|
|
16
22
|
{subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>}
|
|
17
23
|
<div className="pagination-nav__label">{title}</div>
|
|
18
24
|
</Link>
|
|
@@ -109,16 +109,16 @@ export default function SiteMetadata(): JSX.Element {
|
|
|
109
109
|
|
|
110
110
|
<SearchMetadata tag={DEFAULT_SEARCH_TAG} locale={currentLocale} />
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
>
|
|
112
|
+
{/*
|
|
113
|
+
It's important to have an additional <Head> element here, as it allows
|
|
114
|
+
react-helmet to override default metadata values set in previous <Head>
|
|
115
|
+
like "twitter:card". In same Head, the same meta would appear twice
|
|
116
|
+
instead of overriding.
|
|
117
|
+
*/}
|
|
118
|
+
<Head>
|
|
119
119
|
{/* Yes, "metadatum" is the grammatically correct term */}
|
|
120
120
|
{metadata.map((metadatum, i) => (
|
|
121
|
-
<meta key={
|
|
121
|
+
<meta key={i} {...metadatum} />
|
|
122
122
|
))}
|
|
123
123
|
</Head>
|
|
124
124
|
</>
|
|
@@ -5,40 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React
|
|
9
|
-
import {useHistory} from '@docusaurus/router';
|
|
8
|
+
import React from 'react';
|
|
10
9
|
import Translate from '@docusaurus/Translate';
|
|
11
|
-
import {
|
|
10
|
+
import {useSkipToContent} from '@docusaurus/theme-common';
|
|
12
11
|
|
|
13
12
|
import styles from './styles.module.css';
|
|
14
13
|
|
|
15
|
-
function programmaticFocus(el: HTMLElement) {
|
|
16
|
-
el.setAttribute('tabindex', '-1');
|
|
17
|
-
el.focus();
|
|
18
|
-
el.removeAttribute('tabindex');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
14
|
export default function SkipToContent(): JSX.Element {
|
|
22
|
-
const containerRef =
|
|
23
|
-
const {action} = useHistory();
|
|
24
|
-
const handleSkip = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
|
|
27
|
-
const targetElement: HTMLElement | null =
|
|
28
|
-
document.querySelector('main:first-of-type') ||
|
|
29
|
-
document.querySelector('.main-wrapper');
|
|
30
|
-
|
|
31
|
-
if (targetElement) {
|
|
32
|
-
programmaticFocus(targetElement);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
useLocationChange(({location}) => {
|
|
37
|
-
if (containerRef.current && !location.hash && action === 'PUSH') {
|
|
38
|
-
programmaticFocus(containerRef.current);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
15
|
+
const {containerRef, handleSkip} = useSkipToContent();
|
|
42
16
|
return (
|
|
43
17
|
<div ref={containerRef} role="region">
|
|
44
18
|
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
@@ -5,12 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
.tocCollapsible {
|
|
9
|
-
background-color: var(--ifm-menu-color-background-active);
|
|
10
|
-
border-radius: var(--ifm-global-radius);
|
|
11
|
-
margin: 1rem 0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
8
|
.tocCollapsibleButton {
|
|
15
9
|
font-size: inherit;
|
|
16
10
|
display: flex;
|
|
@@ -30,21 +24,6 @@
|
|
|
30
24
|
transition: transform var(--ifm-transition-fast);
|
|
31
25
|
}
|
|
32
26
|
|
|
33
|
-
.
|
|
34
|
-
border-left: none;
|
|
35
|
-
border-top: 1px solid var(--ifm-color-emphasis-300);
|
|
36
|
-
padding: 0.2rem 0;
|
|
37
|
-
font-size: 15px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.tocCollapsibleContent ul li {
|
|
41
|
-
margin: 0.4rem 0.8rem;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.tocCollapsibleContent a {
|
|
45
|
-
display: block;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.tocCollapsibleExpanded .tocCollapsibleButton::after {
|
|
27
|
+
.tocCollapsibleButtonExpanded::after {
|
|
49
28
|
transform: none;
|
|
50
29
|
}
|