@docusaurus/theme-classic 3.0.1 → 3.1.1
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/theme/CodeInline/index.d.ts +9 -0
- package/lib/theme/CodeInline/index.js +13 -0
- package/lib/theme/Heading/index.js +3 -0
- package/lib/theme/MDXComponents/Code.js +15 -3
- package/lib/theme/MDXComponents/Img/index.js +1 -0
- package/lib/theme/MDXComponents/Li.d.ts +9 -0
- package/lib/theme/MDXComponents/Li.js +13 -0
- package/lib/theme/MDXComponents/index.js +2 -0
- package/lib/theme/NavbarItem/DropdownNavbarItem/index.js +3 -0
- package/package.json +14 -15
- package/src/theme/CodeInline/index.tsx +16 -0
- package/src/theme/Heading/index.tsx +4 -0
- package/src/theme/MDXComponents/Code.tsx +13 -5
- package/src/theme/MDXComponents/Img/index.tsx +1 -0
- package/src/theme/MDXComponents/Li.tsx +17 -0
- package/src/theme/MDXComponents/index.tsx +2 -0
- package/src/theme/NavbarItem/DropdownNavbarItem/index.tsx +3 -0
- package/src/theme-classic.d.ts +16 -0
|
@@ -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/CodeInline';
|
|
9
|
+
export default function CodeInline(props: Props): JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
// Simple component used to render inline code blocks
|
|
9
|
+
// its purpose is to be swizzled and customized
|
|
10
|
+
// MDX 1 used to have a inlineCode comp, see https://mdxjs.com/migrating/v2/
|
|
11
|
+
export default function CodeInline(props) {
|
|
12
|
+
return <code {...props} />;
|
|
13
|
+
}
|
|
@@ -9,8 +9,10 @@ import clsx from 'clsx';
|
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
11
|
import Link from '@docusaurus/Link';
|
|
12
|
+
import useBrokenLinks from '@docusaurus/useBrokenLinks';
|
|
12
13
|
import styles from './styles.module.css';
|
|
13
14
|
export default function Heading({as: As, id, ...props}) {
|
|
15
|
+
const brokenLinks = useBrokenLinks();
|
|
14
16
|
const {
|
|
15
17
|
navbar: {hideOnScroll},
|
|
16
18
|
} = useThemeConfig();
|
|
@@ -18,6 +20,7 @@ export default function Heading({as: As, id, ...props}) {
|
|
|
18
20
|
if (As === 'h1' || !id) {
|
|
19
21
|
return <As {...props} id={undefined} />;
|
|
20
22
|
}
|
|
23
|
+
brokenLinks.collectAnchor(id);
|
|
21
24
|
const anchorTitle = translate(
|
|
22
25
|
{
|
|
23
26
|
id: 'theme.common.headingLinkTitle',
|
|
@@ -6,9 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import CodeBlock from '@theme/CodeBlock';
|
|
9
|
+
import CodeInline from '@theme/CodeInline';
|
|
10
|
+
function shouldBeInline(props) {
|
|
11
|
+
return (
|
|
12
|
+
// empty code blocks have no props.children,
|
|
13
|
+
// see https://github.com/facebook/docusaurus/pull/9704
|
|
14
|
+
typeof props.children !== 'undefined' &&
|
|
15
|
+
React.Children.toArray(props.children).every(
|
|
16
|
+
(el) => typeof el === 'string' && !el.includes('\n'),
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
9
20
|
export default function MDXCode(props) {
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
return shouldBeInline(props) ? (
|
|
22
|
+
<CodeInline {...props} />
|
|
23
|
+
) : (
|
|
24
|
+
<CodeBlock {...props} />
|
|
12
25
|
);
|
|
13
|
-
return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
|
|
14
26
|
}
|
|
@@ -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
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
import type { Props } from '@theme/MDXComponents/Li';
|
|
9
|
+
export default function MDXLi(props: Props): ReactNode | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import useBrokenLinks from '@docusaurus/useBrokenLinks';
|
|
9
|
+
export default function MDXLi(props) {
|
|
10
|
+
// MDX Footnotes have ids such as <li id="user-content-fn-1-953011">
|
|
11
|
+
useBrokenLinks().collectAnchor(props.id);
|
|
12
|
+
return <li {...props} />;
|
|
13
|
+
}
|
|
@@ -12,6 +12,7 @@ import MDXPre from '@theme/MDXComponents/Pre';
|
|
|
12
12
|
import MDXDetails from '@theme/MDXComponents/Details';
|
|
13
13
|
import MDXHeading from '@theme/MDXComponents/Heading';
|
|
14
14
|
import MDXUl from '@theme/MDXComponents/Ul';
|
|
15
|
+
import MDXLi from '@theme/MDXComponents/Li';
|
|
15
16
|
import MDXImg from '@theme/MDXComponents/Img';
|
|
16
17
|
import Admonition from '@theme/Admonition';
|
|
17
18
|
import Mermaid from '@theme/Mermaid';
|
|
@@ -23,6 +24,7 @@ const MDXComponents = {
|
|
|
23
24
|
a: MDXA,
|
|
24
25
|
pre: MDXPre,
|
|
25
26
|
ul: MDXUl,
|
|
27
|
+
li: MDXLi,
|
|
26
28
|
img: MDXImg,
|
|
27
29
|
h1: (props) => <MDXHeading as="h1" {...props} />,
|
|
28
30
|
h2: (props) => <MDXHeading as="h2" {...props} />,
|
|
@@ -66,6 +66,9 @@ function DropdownNavbarItemDesktop({
|
|
|
66
66
|
aria-haspopup="true"
|
|
67
67
|
aria-expanded={showDropdown}
|
|
68
68
|
role="button"
|
|
69
|
+
// # hash permits to make the <a> tag focusable in case no link target
|
|
70
|
+
// See https://github.com/facebook/docusaurus/pull/6003
|
|
71
|
+
// There's probably a better solution though...
|
|
69
72
|
href={props.to ? undefined : '#'}
|
|
70
73
|
className={clsx('navbar__link', className)}
|
|
71
74
|
{...props}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "3.
|
|
24
|
-
"@docusaurus/mdx-loader": "3.
|
|
25
|
-
"@docusaurus/module-type-aliases": "3.
|
|
26
|
-
"@docusaurus/plugin-content-blog": "3.
|
|
27
|
-
"@docusaurus/plugin-content-docs": "3.
|
|
28
|
-
"@docusaurus/plugin-content-pages": "3.
|
|
29
|
-
"@docusaurus/theme-common": "3.
|
|
30
|
-
"@docusaurus/theme-translations": "3.
|
|
31
|
-
"@docusaurus/types": "3.
|
|
32
|
-
"@docusaurus/utils": "3.
|
|
33
|
-
"@docusaurus/utils-common": "3.
|
|
34
|
-
"@docusaurus/utils-validation": "3.
|
|
23
|
+
"@docusaurus/core": "3.1.1",
|
|
24
|
+
"@docusaurus/mdx-loader": "3.1.1",
|
|
25
|
+
"@docusaurus/module-type-aliases": "3.1.1",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "3.1.1",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "3.1.1",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "3.1.1",
|
|
29
|
+
"@docusaurus/theme-common": "3.1.1",
|
|
30
|
+
"@docusaurus/theme-translations": "3.1.1",
|
|
31
|
+
"@docusaurus/types": "3.1.1",
|
|
32
|
+
"@docusaurus/utils": "3.1.1",
|
|
33
|
+
"@docusaurus/utils-common": "3.1.1",
|
|
34
|
+
"@docusaurus/utils-validation": "3.1.1",
|
|
35
35
|
"@mdx-js/react": "^3.0.0",
|
|
36
36
|
"clsx": "^2.0.0",
|
|
37
37
|
"copy-text-to-clipboard": "^3.2.0",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"utility-types": "^3.10.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@types/mdx-js__react": "^1.5.5",
|
|
51
50
|
"@types/nprogress": "^0.2.0",
|
|
52
51
|
"@types/prismjs": "^1.26.0",
|
|
53
52
|
"@types/rtlcss": "^3.5.1",
|
|
@@ -62,5 +61,5 @@
|
|
|
62
61
|
"engines": {
|
|
63
62
|
"node": ">=18.0"
|
|
64
63
|
},
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "8017f6a6776ba1bd7065e630a52fe2c2654e2f1b"
|
|
66
65
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 type {Props} from '@theme/CodeInline';
|
|
10
|
+
|
|
11
|
+
// Simple component used to render inline code blocks
|
|
12
|
+
// its purpose is to be swizzled and customized
|
|
13
|
+
// MDX 1 used to have a inlineCode comp, see https://mdxjs.com/migrating/v2/
|
|
14
|
+
export default function CodeInline(props: Props): JSX.Element {
|
|
15
|
+
return <code {...props} />;
|
|
16
|
+
}
|
|
@@ -10,11 +10,13 @@ import clsx from 'clsx';
|
|
|
10
10
|
import {translate} from '@docusaurus/Translate';
|
|
11
11
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
12
12
|
import Link from '@docusaurus/Link';
|
|
13
|
+
import useBrokenLinks from '@docusaurus/useBrokenLinks';
|
|
13
14
|
import type {Props} from '@theme/Heading';
|
|
14
15
|
|
|
15
16
|
import styles from './styles.module.css';
|
|
16
17
|
|
|
17
18
|
export default function Heading({as: As, id, ...props}: Props): JSX.Element {
|
|
19
|
+
const brokenLinks = useBrokenLinks();
|
|
18
20
|
const {
|
|
19
21
|
navbar: {hideOnScroll},
|
|
20
22
|
} = useThemeConfig();
|
|
@@ -23,6 +25,8 @@ export default function Heading({as: As, id, ...props}: Props): JSX.Element {
|
|
|
23
25
|
return <As {...props} id={undefined} />;
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
brokenLinks.collectAnchor(id);
|
|
29
|
+
|
|
26
30
|
const anchorTitle = translate(
|
|
27
31
|
{
|
|
28
32
|
id: 'theme.common.headingLinkTitle',
|
|
@@ -8,15 +8,23 @@
|
|
|
8
8
|
import type {ComponentProps} from 'react';
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import CodeBlock from '@theme/CodeBlock';
|
|
11
|
+
import CodeInline from '@theme/CodeInline';
|
|
11
12
|
import type {Props} from '@theme/MDXComponents/Code';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
function shouldBeInline(props: Props) {
|
|
15
|
+
return (
|
|
16
|
+
// empty code blocks have no props.children,
|
|
17
|
+
// see https://github.com/facebook/docusaurus/pull/9704
|
|
18
|
+
typeof props.children !== 'undefined' &&
|
|
19
|
+
React.Children.toArray(props.children).every(
|
|
20
|
+
(el) => typeof el === 'string' && !el.includes('\n'),
|
|
21
|
+
)
|
|
16
22
|
);
|
|
23
|
+
}
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
export default function MDXCode(props: Props): JSX.Element {
|
|
26
|
+
return shouldBeInline(props) ? (
|
|
27
|
+
<CodeInline {...props} />
|
|
20
28
|
) : (
|
|
21
29
|
<CodeBlock {...(props as ComponentProps<typeof CodeBlock>)} />
|
|
22
30
|
);
|
|
@@ -0,0 +1,17 @@
|
|
|
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, {type ReactNode} from 'react';
|
|
9
|
+
import useBrokenLinks from '@docusaurus/useBrokenLinks';
|
|
10
|
+
import type {Props} from '@theme/MDXComponents/Li';
|
|
11
|
+
|
|
12
|
+
export default function MDXLi(props: Props): ReactNode | undefined {
|
|
13
|
+
// MDX Footnotes have ids such as <li id="user-content-fn-1-953011">
|
|
14
|
+
useBrokenLinks().collectAnchor(props.id);
|
|
15
|
+
|
|
16
|
+
return <li {...props} />;
|
|
17
|
+
}
|
|
@@ -13,6 +13,7 @@ import MDXPre from '@theme/MDXComponents/Pre';
|
|
|
13
13
|
import MDXDetails from '@theme/MDXComponents/Details';
|
|
14
14
|
import MDXHeading from '@theme/MDXComponents/Heading';
|
|
15
15
|
import MDXUl from '@theme/MDXComponents/Ul';
|
|
16
|
+
import MDXLi from '@theme/MDXComponents/Li';
|
|
16
17
|
import MDXImg from '@theme/MDXComponents/Img';
|
|
17
18
|
import Admonition from '@theme/Admonition';
|
|
18
19
|
import Mermaid from '@theme/Mermaid';
|
|
@@ -27,6 +28,7 @@ const MDXComponents: MDXComponentsObject = {
|
|
|
27
28
|
a: MDXA,
|
|
28
29
|
pre: MDXPre,
|
|
29
30
|
ul: MDXUl,
|
|
31
|
+
li: MDXLi,
|
|
30
32
|
img: MDXImg,
|
|
31
33
|
h1: (props: ComponentProps<'h1'>) => <MDXHeading as="h1" {...props} />,
|
|
32
34
|
h2: (props: ComponentProps<'h2'>) => <MDXHeading as="h2" {...props} />,
|
|
@@ -89,6 +89,9 @@ function DropdownNavbarItemDesktop({
|
|
|
89
89
|
aria-haspopup="true"
|
|
90
90
|
aria-expanded={showDropdown}
|
|
91
91
|
role="button"
|
|
92
|
+
// # hash permits to make the <a> tag focusable in case no link target
|
|
93
|
+
// See https://github.com/facebook/docusaurus/pull/6003
|
|
94
|
+
// There's probably a better solution though...
|
|
92
95
|
href={props.to ? undefined : '#'}
|
|
93
96
|
className={clsx('navbar__link', className)}
|
|
94
97
|
{...props}
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -363,6 +363,14 @@ declare module '@theme/CodeBlock' {
|
|
|
363
363
|
export default function CodeBlock(props: Props): JSX.Element;
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
+
declare module '@theme/CodeInline' {
|
|
367
|
+
import type {ComponentProps} from 'react';
|
|
368
|
+
|
|
369
|
+
export interface Props extends ComponentProps<'code'> {}
|
|
370
|
+
|
|
371
|
+
export default function CodeInline(props: Props): JSX.Element;
|
|
372
|
+
}
|
|
373
|
+
|
|
366
374
|
declare module '@theme/CodeBlock/CopyButton' {
|
|
367
375
|
export interface Props {
|
|
368
376
|
readonly code: string;
|
|
@@ -859,6 +867,14 @@ declare module '@theme/MDXComponents/Ul' {
|
|
|
859
867
|
export default function MDXUl(props: Props): JSX.Element;
|
|
860
868
|
}
|
|
861
869
|
|
|
870
|
+
declare module '@theme/MDXComponents/Li' {
|
|
871
|
+
import type {ComponentProps} from 'react';
|
|
872
|
+
|
|
873
|
+
export interface Props extends ComponentProps<'li'> {}
|
|
874
|
+
|
|
875
|
+
export default function MDXLi(props: Props): JSX.Element;
|
|
876
|
+
}
|
|
877
|
+
|
|
862
878
|
declare module '@theme/MDXComponents/Img' {
|
|
863
879
|
import type {ComponentProps} from 'react';
|
|
864
880
|
|