@docusaurus/theme-classic 2.4.1 → 3.0.0-beta.0
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/getSwizzleConfig.js +107 -8
- package/lib/index.js +20 -6
- package/lib/nprogress.d.ts +1 -1
- package/lib/options.js +6 -2
- package/lib/theme/Admonition/Icon/Danger.d.ts +9 -0
- package/lib/theme/Admonition/Icon/Danger.js +17 -0
- package/lib/theme/Admonition/Icon/Info.d.ts +9 -0
- package/lib/theme/Admonition/Icon/Info.js +17 -0
- package/lib/theme/Admonition/Icon/Note.d.ts +9 -0
- package/lib/theme/Admonition/Icon/Note.js +17 -0
- package/lib/theme/Admonition/Icon/Tip.d.ts +9 -0
- package/lib/theme/Admonition/Icon/Tip.js +17 -0
- package/lib/theme/Admonition/Icon/Warning.d.ts +9 -0
- package/lib/theme/Admonition/Icon/Warning.js +17 -0
- package/lib/theme/Admonition/Layout/index.d.ts +9 -0
- package/lib/theme/Admonition/Layout/index.js +45 -0
- package/lib/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
- package/lib/theme/Admonition/Type/Caution.d.ts +9 -0
- package/lib/theme/Admonition/Type/Caution.js +34 -0
- package/lib/theme/Admonition/Type/Danger.d.ts +9 -0
- package/lib/theme/Admonition/Type/Danger.js +32 -0
- package/lib/theme/Admonition/Type/Info.d.ts +9 -0
- package/lib/theme/Admonition/Type/Info.js +32 -0
- package/lib/theme/Admonition/Type/Note.d.ts +9 -0
- package/lib/theme/Admonition/Type/Note.js +32 -0
- package/lib/theme/Admonition/Type/Tip.d.ts +9 -0
- package/lib/theme/Admonition/Type/Tip.js +32 -0
- package/lib/theme/Admonition/Type/Warning.d.ts +9 -0
- package/lib/theme/Admonition/Type/Warning.js +32 -0
- package/lib/theme/Admonition/Types.d.ts +12 -0
- package/lib/theme/Admonition/Types.js +33 -0
- package/lib/theme/Admonition/index.d.ts +1 -1
- package/lib/theme/Admonition/index.js +12 -171
- package/lib/theme/BlogArchivePage/index.js +7 -2
- package/lib/theme/BlogLayout/index.js +1 -1
- package/lib/theme/BlogPostItem/Container/index.js +12 -3
- package/lib/theme/BlogPostItem/Header/Author/index.js +6 -1
- package/lib/theme/BlogPostPage/index.js +3 -1
- package/lib/theme/BlogSidebar/Desktop/index.js +3 -1
- package/lib/theme/BlogSidebar/Mobile/index.js +3 -1
- package/lib/theme/BlogTagsListPage/index.js +2 -1
- package/lib/theme/BlogTagsPostsPage/index.js +4 -2
- package/lib/theme/CodeBlock/Content/String.js +9 -2
- package/lib/theme/CodeBlock/CopyButton/index.js +0 -1
- package/lib/theme/DocBreadcrumbs/index.js +6 -2
- package/lib/theme/DocCard/index.js +8 -4
- package/lib/theme/DocItem/Layout/index.js +5 -0
- package/lib/theme/DocItem/index.js +1 -1
- package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.d.ts +2 -2
- package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.js +1 -1
- package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.d.ts +2 -2
- package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.js +1 -1
- package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.d.ts +2 -2
- package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.js +2 -2
- package/lib/theme/{DocPage → DocRoot}/Layout/index.d.ts +2 -2
- package/lib/theme/{DocPage → DocRoot}/Layout/index.js +9 -10
- package/lib/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
- package/lib/theme/{DocPage → DocRoot}/index.d.ts +2 -2
- package/lib/theme/DocRoot/index.js +31 -0
- package/lib/theme/DocSidebar/Desktop/index.d.ts +1 -1
- package/lib/theme/DocSidebar/Mobile/index.d.ts +1 -1
- package/lib/theme/DocSidebarItem/Category/index.js +24 -13
- package/lib/theme/DocSidebarItems/index.js +6 -4
- package/lib/theme/DocTagDocListPage/index.d.ts +1 -1
- package/lib/theme/DocTagDocListPage/index.js +53 -39
- package/lib/theme/DocTagsListPage/index.d.ts +1 -1
- package/lib/theme/DocTagsListPage/index.js +26 -17
- package/lib/theme/DocVersionRoot/index.d.ts +10 -0
- package/lib/theme/DocVersionRoot/index.js +46 -0
- package/lib/theme/DocsRoot/index.d.ts +10 -0
- package/lib/theme/DocsRoot/index.js +18 -0
- package/lib/theme/EditThisPage/index.js +3 -6
- package/lib/theme/ErrorPageContent.js +3 -2
- package/lib/theme/MDXComponents/Code.js +2 -36
- package/lib/theme/MDXComponents/Details.js +1 -1
- package/lib/theme/MDXComponents/Pre.d.ts +2 -2
- package/lib/theme/MDXComponents/Pre.js +4 -11
- package/lib/theme/MDXComponents/Ul/index.js +4 -0
- package/lib/theme/MDXComponents/index.js +4 -3
- package/lib/theme/MDXPage/index.js +16 -4
- package/lib/theme/NavbarItem/DocNavbarItem.js +4 -3
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.d.ts +1 -1
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +2 -1
- package/lib/theme/NotFound/Content/index.d.ts +9 -0
- package/lib/theme/NotFound/Content/index.js +42 -0
- package/lib/theme/{NotFound.d.ts → NotFound/index.d.ts} +1 -1
- package/lib/theme/NotFound/index.js +25 -0
- package/lib/theme/SiteMetadata/index.js +30 -3
- package/lib/theme/TOCItems/Tree.js +3 -4
- package/lib/theme/Tabs/index.js +4 -2
- package/lib/theme/TagsListByLetter/index.js +4 -1
- package/lib/theme/ThemedImage/index.js +8 -24
- package/lib/theme/{MDXComponents/Head.d.ts → Unlisted/index.d.ts} +2 -2
- package/lib/theme/Unlisted/index.js +38 -0
- package/package.json +26 -26
- package/src/getSwizzleConfig.ts +116 -9
- package/src/index.ts +21 -6
- package/src/nprogress.ts +2 -1
- package/src/options.ts +7 -2
- package/src/theme/Admonition/Icon/Danger.tsx +20 -0
- package/src/theme/Admonition/Icon/Info.tsx +20 -0
- package/src/theme/Admonition/Icon/Note.tsx +20 -0
- package/src/theme/Admonition/Icon/Tip.tsx +20 -0
- package/src/theme/Admonition/Icon/Warning.tsx +20 -0
- package/src/theme/Admonition/Layout/index.tsx +57 -0
- package/src/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
- package/src/theme/Admonition/Type/Caution.tsx +39 -0
- package/src/theme/Admonition/Type/Danger.tsx +37 -0
- package/src/theme/Admonition/Type/Info.tsx +37 -0
- package/src/theme/Admonition/Type/Note.tsx +37 -0
- package/src/theme/Admonition/Type/Tip.tsx +37 -0
- package/src/theme/Admonition/Type/Warning.tsx +37 -0
- package/src/theme/Admonition/Types.tsx +38 -0
- package/src/theme/Admonition/index.tsx +13 -194
- package/src/theme/BlogArchivePage/index.tsx +7 -2
- package/src/theme/BlogLayout/index.tsx +1 -1
- package/src/theme/BlogPostItem/Container/index.tsx +12 -3
- package/src/theme/BlogPostItem/Header/Author/index.tsx +6 -1
- package/src/theme/BlogPostPage/index.tsx +3 -1
- package/src/theme/BlogSidebar/Desktop/index.tsx +3 -1
- package/src/theme/BlogSidebar/Mobile/index.tsx +3 -1
- package/src/theme/BlogTagsListPage/index.tsx +2 -1
- package/src/theme/BlogTagsPostsPage/index.tsx +4 -2
- package/src/theme/CodeBlock/Content/String.tsx +11 -2
- package/src/theme/CodeBlock/CopyButton/index.tsx +0 -1
- package/src/theme/DocBreadcrumbs/index.tsx +6 -2
- package/src/theme/DocCard/index.tsx +11 -6
- package/src/theme/DocItem/Layout/index.tsx +5 -0
- package/src/theme/DocItem/index.tsx +1 -1
- package/src/theme/{DocPage → DocRoot}/Layout/Main/index.tsx +2 -2
- package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.tsx +2 -2
- package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/index.tsx +3 -3
- package/src/theme/{DocPage → DocRoot}/Layout/index.tsx +10 -11
- package/src/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
- package/src/theme/DocRoot/index.tsx +34 -0
- package/src/theme/DocSidebarItem/Category/index.tsx +25 -12
- package/src/theme/DocSidebarItems/index.tsx +6 -4
- package/src/theme/DocTagDocListPage/index.tsx +60 -39
- package/src/theme/DocTagsListPage/index.tsx +33 -17
- package/src/theme/DocVersionRoot/index.tsx +51 -0
- package/src/theme/DocsRoot/index.tsx +22 -0
- package/src/theme/EditThisPage/index.tsx +3 -6
- package/src/theme/ErrorPageContent.tsx +3 -2
- package/src/theme/MDXComponents/Code.tsx +2 -39
- package/src/theme/MDXComponents/Details.tsx +1 -2
- package/src/theme/MDXComponents/Pre.tsx +5 -13
- package/src/theme/MDXComponents/Ul/index.tsx +5 -1
- package/src/theme/MDXComponents/index.tsx +11 -10
- package/src/theme/MDXPage/index.tsx +16 -4
- package/src/theme/NavbarItem/DocNavbarItem.tsx +4 -3
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +2 -1
- package/src/theme/NotFound/Content/index.tsx +45 -0
- package/src/theme/NotFound/index.tsx +27 -0
- package/src/theme/SiteMetadata/index.tsx +36 -3
- package/src/theme/SkipToContent/index.tsx +0 -1
- package/src/theme/TOCItems/Tree.tsx +3 -4
- package/src/theme/Tabs/index.tsx +4 -2
- package/src/theme/TagsListByLetter/index.tsx +4 -2
- package/src/theme/ThemedImage/index.tsx +8 -31
- package/src/theme/Unlisted/index.tsx +42 -0
- package/src/theme/prism-include-languages.ts +2 -1
- package/src/theme-classic.d.ts +146 -21
- package/lib/theme/DocPage/index.js +0 -67
- package/lib/theme/MDXComponents/Head.js +0 -23
- package/lib/theme/NotFound.js +0 -52
- package/src/theme/DocPage/index.tsx +0 -71
- package/src/theme/MDXComponents/Head.tsx +0 -29
- package/src/theme/NotFound.tsx +0 -54
- /package/lib/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
- /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
- /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
- /package/src/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
- /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
- /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
|
@@ -4,16 +4,9 @@
|
|
|
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 React
|
|
8
|
-
import CodeBlock from '@theme/CodeBlock';
|
|
7
|
+
import React from 'react';
|
|
9
8
|
export default function MDXPre(props) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
{...(isValidElement(props.children) &&
|
|
14
|
-
props.children.props?.originalType === 'code'
|
|
15
|
-
? props.children.props
|
|
16
|
-
: {...props})}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
9
|
+
// With MDX 2, this element is only used for fenced code blocks
|
|
10
|
+
// It always receives a MDXComponents/Code as children
|
|
11
|
+
return <>{props.children}</>;
|
|
19
12
|
}
|
|
@@ -8,6 +8,10 @@ import React from 'react';
|
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import styles from './styles.module.css';
|
|
10
10
|
function transformUlClassName(className) {
|
|
11
|
+
// Fix https://github.com/facebook/docusaurus/issues/9098
|
|
12
|
+
if (typeof className === 'undefined') {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
11
15
|
return clsx(
|
|
12
16
|
className,
|
|
13
17
|
// This class is set globally by GitHub/MDX. We keep the global class, and
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import
|
|
8
|
+
import Head from '@docusaurus/Head';
|
|
9
9
|
import MDXCode from '@theme/MDXComponents/Code';
|
|
10
10
|
import MDXA from '@theme/MDXComponents/A';
|
|
11
11
|
import MDXPre from '@theme/MDXComponents/Pre';
|
|
@@ -16,11 +16,12 @@ import MDXImg from '@theme/MDXComponents/Img';
|
|
|
16
16
|
import Admonition from '@theme/Admonition';
|
|
17
17
|
import Mermaid from '@theme/Mermaid';
|
|
18
18
|
const MDXComponents = {
|
|
19
|
-
|
|
19
|
+
Head,
|
|
20
|
+
details: MDXDetails,
|
|
21
|
+
Details: MDXDetails,
|
|
20
22
|
code: MDXCode,
|
|
21
23
|
a: MDXA,
|
|
22
24
|
pre: MDXPre,
|
|
23
|
-
details: MDXDetails,
|
|
24
25
|
ul: MDXUl,
|
|
25
26
|
img: MDXImg,
|
|
26
27
|
h1: (props) => <MDXHeading as="h1" {...props} />,
|
|
@@ -14,25 +14,37 @@ import {
|
|
|
14
14
|
import Layout from '@theme/Layout';
|
|
15
15
|
import MDXContent from '@theme/MDXContent';
|
|
16
16
|
import TOC from '@theme/TOC';
|
|
17
|
+
import Unlisted from '@theme/Unlisted';
|
|
17
18
|
import styles from './styles.module.css';
|
|
18
19
|
export default function MDXPage(props) {
|
|
19
20
|
const {content: MDXPageContent} = props;
|
|
20
21
|
const {
|
|
21
|
-
metadata: {title, description, frontMatter},
|
|
22
|
+
metadata: {title, description, frontMatter, unlisted},
|
|
23
|
+
assets,
|
|
22
24
|
} = MDXPageContent;
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
+
const {
|
|
26
|
+
keywords,
|
|
27
|
+
wrapperClassName,
|
|
28
|
+
hide_table_of_contents: hideTableOfContents,
|
|
29
|
+
} = frontMatter;
|
|
30
|
+
const image = assets.image ?? frontMatter.image;
|
|
25
31
|
return (
|
|
26
32
|
<HtmlClassNameProvider
|
|
27
33
|
className={clsx(
|
|
28
34
|
wrapperClassName ?? ThemeClassNames.wrapper.mdxPages,
|
|
29
35
|
ThemeClassNames.page.mdxPage,
|
|
30
36
|
)}>
|
|
31
|
-
<PageMetadata title={title} description={description} />
|
|
32
37
|
<Layout>
|
|
38
|
+
<PageMetadata
|
|
39
|
+
title={title}
|
|
40
|
+
description={description}
|
|
41
|
+
keywords={keywords}
|
|
42
|
+
image={image}
|
|
43
|
+
/>
|
|
33
44
|
<main className="container container--fluid margin-vert--lg">
|
|
34
45
|
<div className={clsx('row', styles.mdxPageWrapper)}>
|
|
35
46
|
<div className={clsx('col', !hideTableOfContents && 'col--8')}>
|
|
47
|
+
{unlisted && <Unlisted />}
|
|
36
48
|
<article>
|
|
37
49
|
<MDXContent>
|
|
38
50
|
<MDXPageContent />
|
|
@@ -16,8 +16,9 @@ export default function DocNavbarItem({
|
|
|
16
16
|
}) {
|
|
17
17
|
const {activeDoc} = useActiveDocContext(docsPluginId);
|
|
18
18
|
const doc = useLayoutDoc(docId, docsPluginId);
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const pageActive = activeDoc?.path === doc?.path;
|
|
20
|
+
// Draft and unlisted items are not displayed in the navbar.
|
|
21
|
+
if (doc === null || (doc.unlisted && !pageActive)) {
|
|
21
22
|
return null;
|
|
22
23
|
}
|
|
23
24
|
return (
|
|
@@ -25,7 +26,7 @@ export default function DocNavbarItem({
|
|
|
25
26
|
exact
|
|
26
27
|
{...props}
|
|
27
28
|
isActive={() =>
|
|
28
|
-
|
|
29
|
+
pageActive ||
|
|
29
30
|
(!!activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar)
|
|
30
31
|
}
|
|
31
32
|
label={staticLabel ?? doc.id}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="react" />
|
|
8
8
|
import type { Props } from '@theme/NavbarItem/LocaleDropdownNavbarItem';
|
|
9
|
-
export default function LocaleDropdownNavbarItem({ mobile, dropdownItemsBefore, dropdownItemsAfter, ...props }: Props): JSX.Element;
|
|
9
|
+
export default function LocaleDropdownNavbarItem({ mobile, dropdownItemsBefore, dropdownItemsAfter, queryString, ...props }: Props): JSX.Element;
|
|
@@ -16,6 +16,7 @@ export default function LocaleDropdownNavbarItem({
|
|
|
16
16
|
mobile,
|
|
17
17
|
dropdownItemsBefore,
|
|
18
18
|
dropdownItemsAfter,
|
|
19
|
+
queryString = '',
|
|
19
20
|
...props
|
|
20
21
|
}) {
|
|
21
22
|
const {
|
|
@@ -29,7 +30,7 @@ export default function LocaleDropdownNavbarItem({
|
|
|
29
30
|
fullyQualified: false,
|
|
30
31
|
})}`;
|
|
31
32
|
// preserve ?search#hash suffix on locale switches
|
|
32
|
-
const to = `${baseTo}${search}${hash}`;
|
|
33
|
+
const to = `${baseTo}${search}${hash}${queryString}`;
|
|
33
34
|
return {
|
|
34
35
|
label: localeConfigs[locale].label,
|
|
35
36
|
lang: localeConfigs[locale].htmlLang,
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
8
|
+
import type { Props } from '@theme/NotFound/Content';
|
|
9
|
+
export default function NotFoundContent({ className }: Props): JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 React from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import Translate from '@docusaurus/Translate';
|
|
10
|
+
import Heading from '@theme/Heading';
|
|
11
|
+
export default function NotFoundContent({className}) {
|
|
12
|
+
return (
|
|
13
|
+
<main className={clsx('container margin-vert--xl', className)}>
|
|
14
|
+
<div className="row">
|
|
15
|
+
<div className="col col--6 col--offset-3">
|
|
16
|
+
<Heading as="h1" className="hero__title">
|
|
17
|
+
<Translate
|
|
18
|
+
id="theme.NotFound.title"
|
|
19
|
+
description="The title of the 404 page">
|
|
20
|
+
Page Not Found
|
|
21
|
+
</Translate>
|
|
22
|
+
</Heading>
|
|
23
|
+
<p>
|
|
24
|
+
<Translate
|
|
25
|
+
id="theme.NotFound.p1"
|
|
26
|
+
description="The first paragraph of the 404 page">
|
|
27
|
+
We could not find what you were looking for.
|
|
28
|
+
</Translate>
|
|
29
|
+
</p>
|
|
30
|
+
<p>
|
|
31
|
+
<Translate
|
|
32
|
+
id="theme.NotFound.p2"
|
|
33
|
+
description="The 2nd paragraph of the 404 page">
|
|
34
|
+
Please contact the owner of the site that linked you to the
|
|
35
|
+
original URL and let them know their link is broken.
|
|
36
|
+
</Translate>
|
|
37
|
+
</p>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</main>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 React from 'react';
|
|
8
|
+
import {translate} from '@docusaurus/Translate';
|
|
9
|
+
import {PageMetadata} from '@docusaurus/theme-common';
|
|
10
|
+
import Layout from '@theme/Layout';
|
|
11
|
+
import NotFoundContent from '@theme/NotFound/Content';
|
|
12
|
+
export default function Index() {
|
|
13
|
+
const title = translate({
|
|
14
|
+
id: 'theme.NotFound.title',
|
|
15
|
+
message: 'Page Not Found',
|
|
16
|
+
});
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<PageMetadata title={title} />
|
|
20
|
+
<Layout>
|
|
21
|
+
<NotFoundContent />
|
|
22
|
+
</Layout>
|
|
23
|
+
</>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
keyboardFocusedClassName,
|
|
16
16
|
} from '@docusaurus/theme-common/internal';
|
|
17
17
|
import {useLocation} from '@docusaurus/router';
|
|
18
|
+
import {applyTrailingSlash} from '@docusaurus/utils-common';
|
|
18
19
|
import SearchMetadata from '@theme/SearchMetadata';
|
|
19
20
|
// TODO move to SiteMetadataDefaults or theme-common ?
|
|
20
21
|
// Useful for i18n/SEO
|
|
@@ -22,9 +23,15 @@ import SearchMetadata from '@theme/SearchMetadata';
|
|
|
22
23
|
// See https://github.com/facebook/docusaurus/issues/3317
|
|
23
24
|
function AlternateLangHeaders() {
|
|
24
25
|
const {
|
|
25
|
-
i18n: {defaultLocale, localeConfigs},
|
|
26
|
+
i18n: {currentLocale, defaultLocale, localeConfigs},
|
|
26
27
|
} = useDocusaurusContext();
|
|
27
28
|
const alternatePageUtils = useAlternatePageUtils();
|
|
29
|
+
const currentHtmlLang = localeConfigs[currentLocale].htmlLang;
|
|
30
|
+
// HTML lang is a BCP 47 tag, but the Open Graph protocol requires
|
|
31
|
+
// using underscores instead of dashes.
|
|
32
|
+
// See https://ogp.me/#optional
|
|
33
|
+
// See https://en.wikipedia.org/wiki/IETF_language_tag)
|
|
34
|
+
const bcp47ToOpenGraphLocale = (code) => code.replace('-', '_');
|
|
28
35
|
// Note: it is fine to use both "x-default" and "en" to target the same url
|
|
29
36
|
// See https://www.searchviu.com/en/multiple-hreflang-tags-one-url/
|
|
30
37
|
return (
|
|
@@ -48,16 +55,36 @@ function AlternateLangHeaders() {
|
|
|
48
55
|
})}
|
|
49
56
|
hrefLang="x-default"
|
|
50
57
|
/>
|
|
58
|
+
|
|
59
|
+
<meta
|
|
60
|
+
property="og:locale"
|
|
61
|
+
content={bcp47ToOpenGraphLocale(currentHtmlLang)}
|
|
62
|
+
/>
|
|
63
|
+
{Object.values(localeConfigs)
|
|
64
|
+
.filter((config) => currentHtmlLang !== config.htmlLang)
|
|
65
|
+
.map((config) => (
|
|
66
|
+
<meta
|
|
67
|
+
key={`meta-og-${config.htmlLang}`}
|
|
68
|
+
property="og:locale:alternate"
|
|
69
|
+
content={bcp47ToOpenGraphLocale(config.htmlLang)}
|
|
70
|
+
/>
|
|
71
|
+
))}
|
|
51
72
|
</Head>
|
|
52
73
|
);
|
|
53
74
|
}
|
|
54
75
|
// Default canonical url inferred from current page location pathname
|
|
55
76
|
function useDefaultCanonicalUrl() {
|
|
56
77
|
const {
|
|
57
|
-
siteConfig: {url: siteUrl},
|
|
78
|
+
siteConfig: {url: siteUrl, baseUrl, trailingSlash},
|
|
58
79
|
} = useDocusaurusContext();
|
|
80
|
+
// TODO using useLocation().pathname is not a super idea
|
|
81
|
+
// See https://github.com/facebook/docusaurus/issues/9170
|
|
59
82
|
const {pathname} = useLocation();
|
|
60
|
-
|
|
83
|
+
const canonicalPathname = applyTrailingSlash(useBaseUrl(pathname), {
|
|
84
|
+
trailingSlash,
|
|
85
|
+
baseUrl,
|
|
86
|
+
});
|
|
87
|
+
return siteUrl + canonicalPathname;
|
|
61
88
|
}
|
|
62
89
|
// TODO move to SiteMetadataDefaults or theme-common ?
|
|
63
90
|
function CanonicalUrlHeaders({permalink}) {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import Link from '@docusaurus/Link';
|
|
8
9
|
// Recursive component rendering the toc tree
|
|
9
10
|
function TOCItemTree({toc, className, linkClassName, isChild}) {
|
|
10
11
|
if (!toc.length) {
|
|
@@ -14,12 +15,10 @@ function TOCItemTree({toc, className, linkClassName, isChild}) {
|
|
|
14
15
|
<ul className={isChild ? undefined : className}>
|
|
15
16
|
{toc.map((heading) => (
|
|
16
17
|
<li key={heading.id}>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
href={`#${heading.id}`}
|
|
18
|
+
<Link
|
|
19
|
+
to={`#${heading.id}`}
|
|
20
20
|
className={linkClassName ?? undefined}
|
|
21
21
|
// Developer provided the HTML, so assume it's safe.
|
|
22
|
-
// eslint-disable-next-line react/no-danger
|
|
23
22
|
dangerouslySetInnerHTML={{__html: heading.value}}
|
|
24
23
|
/>
|
|
25
24
|
<TOCItemTree
|
package/lib/theme/Tabs/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import clsx from 'clsx';
|
|
|
9
9
|
import {
|
|
10
10
|
useScrollPositionBlocker,
|
|
11
11
|
useTabs,
|
|
12
|
+
sanitizeTabsChildren,
|
|
12
13
|
} from '@docusaurus/theme-common/internal';
|
|
13
14
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
14
15
|
import styles from './styles.module.css';
|
|
@@ -119,7 +120,8 @@ export default function Tabs(props) {
|
|
|
119
120
|
// Remount tabs after hydration
|
|
120
121
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
121
122
|
key={String(isBrowser)}
|
|
122
|
-
{...props}
|
|
123
|
-
|
|
123
|
+
{...props}>
|
|
124
|
+
{sanitizeTabsChildren(props.children)}
|
|
125
|
+
</TabsComponent>
|
|
124
126
|
);
|
|
125
127
|
}
|
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import {listTagsByLetters} from '@docusaurus/theme-common';
|
|
9
9
|
import Tag from '@theme/Tag';
|
|
10
|
+
import Heading from '@theme/Heading';
|
|
10
11
|
import styles from './styles.module.css';
|
|
11
12
|
function TagLetterEntryItem({letterEntry}) {
|
|
12
13
|
return (
|
|
13
14
|
<article>
|
|
14
|
-
<h2
|
|
15
|
+
<Heading as="h2" id={letterEntry.letter}>
|
|
16
|
+
{letterEntry.letter}
|
|
17
|
+
</Heading>
|
|
15
18
|
<ul className="padding--none">
|
|
16
19
|
{letterEntry.tags.map((tag) => (
|
|
17
20
|
<li key={tag.permalink} className={styles.tag}>
|
|
@@ -5,35 +5,19 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import
|
|
9
|
-
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
|
-
import {useColorMode} from '@docusaurus/theme-common';
|
|
11
|
-
import styles from './styles.module.css';
|
|
8
|
+
import {ThemedComponent} from '@docusaurus/theme-common';
|
|
12
9
|
export default function ThemedImage(props) {
|
|
13
|
-
const
|
|
14
|
-
const {colorMode} = useColorMode();
|
|
15
|
-
const {sources, className, alt, ...propsRest} = props;
|
|
16
|
-
const clientThemes = colorMode === 'dark' ? ['dark'] : ['light'];
|
|
17
|
-
const renderedSourceNames = isBrowser
|
|
18
|
-
? clientThemes
|
|
19
|
-
: // We need to render both images on the server to avoid flash
|
|
20
|
-
// See https://github.com/facebook/docusaurus/pull/3730
|
|
21
|
-
['light', 'dark'];
|
|
10
|
+
const {sources, className: parentClassName, alt, ...propsRest} = props;
|
|
22
11
|
return (
|
|
23
|
-
|
|
24
|
-
{
|
|
12
|
+
<ThemedComponent className={parentClassName}>
|
|
13
|
+
{({theme, className}) => (
|
|
25
14
|
<img
|
|
26
|
-
|
|
27
|
-
src={sources[sourceName]}
|
|
15
|
+
src={sources[theme]}
|
|
28
16
|
alt={alt}
|
|
29
|
-
className={
|
|
30
|
-
styles.themedImage,
|
|
31
|
-
styles[`themedImage--${sourceName}`],
|
|
32
|
-
className,
|
|
33
|
-
)}
|
|
17
|
+
className={className}
|
|
34
18
|
{...propsRest}
|
|
35
19
|
/>
|
|
36
|
-
)
|
|
37
|
-
|
|
20
|
+
)}
|
|
21
|
+
</ThemedComponent>
|
|
38
22
|
);
|
|
39
23
|
}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="react" />
|
|
8
|
-
import type { Props } from '@theme/
|
|
9
|
-
export default function
|
|
8
|
+
import type { Props } from '@theme/Unlisted';
|
|
9
|
+
export default function Unlisted(props: Props): JSX.Element | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 React from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import {
|
|
10
|
+
ThemeClassNames,
|
|
11
|
+
UnlistedBannerTitle,
|
|
12
|
+
UnlistedBannerMessage,
|
|
13
|
+
UnlistedMetadata,
|
|
14
|
+
} from '@docusaurus/theme-common';
|
|
15
|
+
import Admonition from '@theme/Admonition';
|
|
16
|
+
function UnlistedBanner({className}) {
|
|
17
|
+
return (
|
|
18
|
+
<Admonition
|
|
19
|
+
type="caution"
|
|
20
|
+
title={<UnlistedBannerTitle />}
|
|
21
|
+
className={clsx(className, ThemeClassNames.common.unlistedBanner)}>
|
|
22
|
+
<UnlistedBannerMessage />
|
|
23
|
+
</Admonition>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
export default function Unlisted(props) {
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
{/*
|
|
30
|
+
Unlisted metadata declared here for simplicity.
|
|
31
|
+
Ensures we never forget to add the correct noindex metadata.
|
|
32
|
+
Also gives a central place for user to swizzle override default metadata.
|
|
33
|
+
*/}
|
|
34
|
+
<UnlistedMetadata />
|
|
35
|
+
<UnlistedBanner {...props} />
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,47 +20,47 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "
|
|
24
|
-
"@docusaurus/mdx-loader": "
|
|
25
|
-
"@docusaurus/module-type-aliases": "
|
|
26
|
-
"@docusaurus/plugin-content-blog": "
|
|
27
|
-
"@docusaurus/plugin-content-docs": "
|
|
28
|
-
"@docusaurus/plugin-content-pages": "
|
|
29
|
-
"@docusaurus/theme-common": "
|
|
30
|
-
"@docusaurus/theme-translations": "
|
|
31
|
-
"@docusaurus/types": "
|
|
32
|
-
"@docusaurus/utils": "
|
|
33
|
-
"@docusaurus/utils-common": "
|
|
34
|
-
"@docusaurus/utils-validation": "
|
|
35
|
-
"@mdx-js/react": "^1.
|
|
23
|
+
"@docusaurus/core": "3.0.0-beta.0",
|
|
24
|
+
"@docusaurus/mdx-loader": "3.0.0-beta.0",
|
|
25
|
+
"@docusaurus/module-type-aliases": "3.0.0-beta.0",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "3.0.0-beta.0",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "3.0.0-beta.0",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "3.0.0-beta.0",
|
|
29
|
+
"@docusaurus/theme-common": "3.0.0-beta.0",
|
|
30
|
+
"@docusaurus/theme-translations": "3.0.0-beta.0",
|
|
31
|
+
"@docusaurus/types": "3.0.0-beta.0",
|
|
32
|
+
"@docusaurus/utils": "3.0.0-beta.0",
|
|
33
|
+
"@docusaurus/utils-common": "3.0.0-beta.0",
|
|
34
|
+
"@docusaurus/utils-validation": "3.0.0-beta.0",
|
|
35
|
+
"@mdx-js/react": "^2.1.5",
|
|
36
36
|
"clsx": "^1.2.1",
|
|
37
|
-
"copy-text-to-clipboard": "^3.0
|
|
37
|
+
"copy-text-to-clipboard": "^3.2.0",
|
|
38
38
|
"infima": "0.2.0-alpha.43",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
40
40
|
"nprogress": "^0.2.0",
|
|
41
|
-
"postcss": "^8.4.
|
|
41
|
+
"postcss": "^8.4.26",
|
|
42
42
|
"prism-react-renderer": "^1.3.5",
|
|
43
|
-
"prismjs": "^1.
|
|
44
|
-
"react-router-dom": "^5.3.
|
|
45
|
-
"rtlcss": "^
|
|
46
|
-
"tslib": "^2.
|
|
43
|
+
"prismjs": "^1.29.0",
|
|
44
|
+
"react-router-dom": "^5.3.4",
|
|
45
|
+
"rtlcss": "^4.1.0",
|
|
46
|
+
"tslib": "^2.6.0",
|
|
47
47
|
"utility-types": "^3.10.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/mdx-js__react": "^1.5.5",
|
|
51
51
|
"@types/nprogress": "^0.2.0",
|
|
52
52
|
"@types/prismjs": "^1.26.0",
|
|
53
|
-
"@types/rtlcss": "^3.5.
|
|
54
|
-
"fs-extra": "^
|
|
55
|
-
"react-test-renderer": "^
|
|
53
|
+
"@types/rtlcss": "^3.5.1",
|
|
54
|
+
"fs-extra": "^11.1.1",
|
|
55
|
+
"react-test-renderer": "^18.0.0",
|
|
56
56
|
"utility-types": "^3.10.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"react": "^
|
|
60
|
-
"react-dom": "^
|
|
59
|
+
"react": "^18.0.0",
|
|
60
|
+
"react-dom": "^18.0.0"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=16.14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "27a1e90d9fff88af90ecad35bea16d4d7230482a"
|
|
66
66
|
}
|