@docusaurus/theme-classic 0.0.0-4762 → 0.0.0-4767
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 +56 -0
- package/lib/theme-classic.d.ts +82 -9
- package/lib-next/theme/CodeBlock/CopyButton/index.js +7 -7
- package/lib-next/theme/DocSidebarItem/index.js +2 -4
- package/lib-next/theme/Footer/LinkItem/index.js +2 -4
- package/lib-next/theme/MDXComponents/A.js +11 -0
- package/lib-next/theme/MDXComponents/Code.js +28 -0
- package/lib-next/theme/MDXComponents/Details.js +20 -0
- package/lib-next/theme/MDXComponents/Head.js +26 -0
- package/lib-next/theme/MDXComponents/Heading.js +11 -0
- package/lib-next/theme/MDXComponents/Img.js +18 -0
- package/lib-next/theme/MDXComponents/Img.module.css +10 -0
- package/lib-next/theme/MDXComponents/Pre.js +18 -0
- package/lib-next/theme/MDXComponents/Ul.js +23 -0
- package/lib-next/theme/MDXComponents/{styles.css → Ul.module.css} +1 -5
- package/lib-next/theme/MDXComponents/index.js +22 -71
- package/lib-next/theme/NavbarItem/NavbarNavLink.js +9 -11
- package/package.json +13 -13
- package/src/getSwizzleConfig.ts +62 -0
- package/src/theme/CodeBlock/CopyButton/index.tsx +8 -6
- package/src/theme/DocSidebarItem/index.tsx +2 -4
- package/src/theme/Footer/LinkItem/index.tsx +2 -4
- package/src/theme/MDXComponents/A.tsx +14 -0
- package/src/theme/MDXComponents/Code.tsx +37 -0
- package/src/theme/MDXComponents/Details.tsx +26 -0
- package/src/theme/MDXComponents/Head.tsx +29 -0
- package/src/theme/MDXComponents/Heading.tsx +14 -0
- package/src/theme/MDXComponents/Img.module.css +10 -0
- package/src/theme/MDXComponents/Img.tsx +20 -0
- package/src/theme/MDXComponents/Pre.tsx +21 -0
- package/src/theme/MDXComponents/{styles.css → Ul.module.css} +1 -5
- package/src/theme/MDXComponents/Ul.tsx +28 -0
- package/src/theme/MDXComponents/index.tsx +23 -80
- package/src/theme/NavbarItem/NavbarNavLink.tsx +4 -6
- package/src/theme-classic.d.ts +82 -9
package/lib/getSwizzleConfig.js
CHANGED
|
@@ -137,6 +137,62 @@ function getSwizzleConfig() {
|
|
|
137
137
|
},
|
|
138
138
|
description: 'The MDX components to use for rendering MDX files. Meant to be ejected.'
|
|
139
139
|
},
|
|
140
|
+
'MDXComponents/A': {
|
|
141
|
+
actions: {
|
|
142
|
+
eject: 'safe',
|
|
143
|
+
wrap: 'safe'
|
|
144
|
+
},
|
|
145
|
+
description: 'The component used to render <a> tags and Markdown links in MDX'
|
|
146
|
+
},
|
|
147
|
+
'MDXComponents/Code': {
|
|
148
|
+
actions: {
|
|
149
|
+
eject: 'safe',
|
|
150
|
+
wrap: 'safe'
|
|
151
|
+
},
|
|
152
|
+
description: 'The component used to render <code> tags and Markdown code blocks in MDX'
|
|
153
|
+
},
|
|
154
|
+
'MDXComponents/Details': {
|
|
155
|
+
actions: {
|
|
156
|
+
eject: 'safe',
|
|
157
|
+
wrap: 'safe'
|
|
158
|
+
},
|
|
159
|
+
description: 'The component used to render <details> tags in MDX'
|
|
160
|
+
},
|
|
161
|
+
'MDXComponents/Head': {
|
|
162
|
+
actions: {
|
|
163
|
+
eject: 'forbidden',
|
|
164
|
+
wrap: 'forbidden'
|
|
165
|
+
},
|
|
166
|
+
description: 'Technical component used to assign metadata (generally for SEO purpose) to the current MDX document'
|
|
167
|
+
},
|
|
168
|
+
'MDXComponents/Heading': {
|
|
169
|
+
actions: {
|
|
170
|
+
eject: 'safe',
|
|
171
|
+
wrap: 'safe'
|
|
172
|
+
},
|
|
173
|
+
description: 'The component used to render heading tags (<h1>, <h2>...) and Markdown headings in MDX'
|
|
174
|
+
},
|
|
175
|
+
'MDXComponents/Img': {
|
|
176
|
+
actions: {
|
|
177
|
+
eject: 'safe',
|
|
178
|
+
wrap: 'safe'
|
|
179
|
+
},
|
|
180
|
+
description: 'The component used to render <img> tags and Markdown images in MDX'
|
|
181
|
+
},
|
|
182
|
+
'MDXComponents/Pre': {
|
|
183
|
+
actions: {
|
|
184
|
+
eject: 'safe',
|
|
185
|
+
wrap: 'safe'
|
|
186
|
+
},
|
|
187
|
+
description: 'The component used to render <pre> tags in MDX'
|
|
188
|
+
},
|
|
189
|
+
'MDXComponents/Ul': {
|
|
190
|
+
actions: {
|
|
191
|
+
eject: 'safe',
|
|
192
|
+
wrap: 'safe'
|
|
193
|
+
},
|
|
194
|
+
description: 'The component used to render <ul> tags and Markdown unordered lists in MDX'
|
|
195
|
+
},
|
|
140
196
|
MDXContent: {
|
|
141
197
|
actions: {
|
|
142
198
|
eject: 'safe',
|
package/lib/theme-classic.d.ts
CHANGED
|
@@ -417,24 +417,97 @@ declare module '@theme/SkipToContent' {
|
|
|
417
417
|
export default function SkipToContent(): JSX.Element;
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
declare module '@theme/MDXComponents' {
|
|
420
|
+
declare module '@theme/MDXComponents/A' {
|
|
421
|
+
import type {ComponentProps} from 'react';
|
|
422
|
+
|
|
423
|
+
export interface Props extends ComponentProps<'a'> {}
|
|
424
|
+
|
|
425
|
+
export default function MDXA(props: Props): JSX.Element;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
declare module '@theme/MDXComponents/Code' {
|
|
429
|
+
import type {ComponentProps} from 'react';
|
|
430
|
+
|
|
431
|
+
export interface Props extends ComponentProps<'code'> {}
|
|
432
|
+
|
|
433
|
+
export default function MDXCode(props: Props): JSX.Element;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
declare module '@theme/MDXComponents/Details' {
|
|
421
437
|
import type {ComponentProps} from 'react';
|
|
422
|
-
|
|
423
|
-
|
|
438
|
+
|
|
439
|
+
export interface Props extends ComponentProps<'details'> {}
|
|
440
|
+
|
|
441
|
+
export default function MDXDetails(props: Props): JSX.Element;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
declare module '@theme/MDXComponents/Ul' {
|
|
445
|
+
import type {ComponentProps} from 'react';
|
|
446
|
+
|
|
447
|
+
export interface Props extends ComponentProps<'ul'> {}
|
|
448
|
+
|
|
449
|
+
export default function MDXUl(props: Props): JSX.Element;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
declare module '@theme/MDXComponents/Img' {
|
|
453
|
+
import type {ComponentProps} from 'react';
|
|
454
|
+
|
|
455
|
+
export interface Props extends ComponentProps<'img'> {}
|
|
456
|
+
|
|
457
|
+
export default function MDXImg(props: Props): JSX.Element;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
declare module '@theme/MDXComponents/Head' {
|
|
461
|
+
import type {ComponentProps} from 'react';
|
|
462
|
+
|
|
463
|
+
export interface Props extends ComponentProps<'head'> {}
|
|
464
|
+
|
|
465
|
+
export default function MDXHead(props: Props): JSX.Element;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
declare module '@theme/MDXComponents/Heading' {
|
|
469
|
+
import type {ComponentProps} from 'react';
|
|
470
|
+
import type Heading from '@theme/Heading';
|
|
471
|
+
|
|
472
|
+
export interface Props extends ComponentProps<typeof Heading> {}
|
|
473
|
+
|
|
474
|
+
export default function MDXHeading(props: Props): JSX.Element;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
declare module '@theme/MDXComponents/Pre' {
|
|
478
|
+
import type {ComponentProps} from 'react';
|
|
479
|
+
|
|
480
|
+
export interface Props extends ComponentProps<'pre'> {}
|
|
481
|
+
|
|
482
|
+
export default function MDXPre(props: Props): JSX.Element;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
declare module '@theme/MDXComponents' {
|
|
486
|
+
import type {ComponentType, ComponentProps} from 'react';
|
|
487
|
+
|
|
488
|
+
import type MDXHead from '@theme/MDXComponents/Head';
|
|
489
|
+
import type MDXCode from '@theme/MDXComponents/Code';
|
|
490
|
+
import type MDXA from '@theme/MDXComponents/A';
|
|
491
|
+
import type MDXPre from '@theme/MDXComponents/Pre';
|
|
492
|
+
import type MDXDetails from '@theme/MDXComponents/Details';
|
|
493
|
+
import type MDXUl from '@theme/MDXComponents/Ul';
|
|
494
|
+
import type MDXImg from '@theme/MDXComponents/Img';
|
|
424
495
|
|
|
425
496
|
export type MDXComponentsObject = {
|
|
426
|
-
readonly head: typeof
|
|
427
|
-
readonly code: typeof
|
|
428
|
-
readonly a:
|
|
429
|
-
readonly pre: typeof
|
|
430
|
-
readonly details:
|
|
497
|
+
readonly head: typeof MDXHead;
|
|
498
|
+
readonly code: typeof MDXCode;
|
|
499
|
+
readonly a: typeof MDXA;
|
|
500
|
+
readonly pre: typeof MDXPre;
|
|
501
|
+
readonly details: typeof MDXDetails;
|
|
502
|
+
readonly ul: typeof MDXUl;
|
|
503
|
+
readonly img: typeof MDXImg;
|
|
431
504
|
readonly h1: (props: ComponentProps<'h1'>) => JSX.Element;
|
|
432
505
|
readonly h2: (props: ComponentProps<'h2'>) => JSX.Element;
|
|
433
506
|
readonly h3: (props: ComponentProps<'h3'>) => JSX.Element;
|
|
434
507
|
readonly h4: (props: ComponentProps<'h4'>) => JSX.Element;
|
|
435
508
|
readonly h5: (props: ComponentProps<'h5'>) => JSX.Element;
|
|
436
509
|
readonly h6: (props: ComponentProps<'h6'>) => JSX.Element;
|
|
437
|
-
}
|
|
510
|
+
} & Record<string, ComponentType<unknown>>;
|
|
438
511
|
|
|
439
512
|
const MDXComponents: MDXComponentsObject;
|
|
440
513
|
export default MDXComponents;
|
|
@@ -4,22 +4,22 @@
|
|
|
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, {useState} from 'react';
|
|
7
|
+
import React, {useCallback, useState, useRef, useEffect} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import copy from 'copy-text-to-clipboard';
|
|
10
10
|
import {translate} from '@docusaurus/Translate';
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
12
|
export default function CopyButton({code}) {
|
|
13
13
|
const [isCopied, setIsCopied] = useState(false);
|
|
14
|
-
|
|
15
|
-
const handleCopyCode = () => {
|
|
14
|
+
const copyTimeout = useRef(undefined);
|
|
15
|
+
const handleCopyCode = useCallback(() => {
|
|
16
16
|
copy(code);
|
|
17
17
|
setIsCopied(true);
|
|
18
|
-
setTimeout(() => {
|
|
18
|
+
copyTimeout.current = window.setTimeout(() => {
|
|
19
19
|
setIsCopied(false);
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
20
|
+
}, 1000);
|
|
21
|
+
}, [code]);
|
|
22
|
+
useEffect(() => () => window.clearTimeout(copyTimeout.current), []);
|
|
23
23
|
return (
|
|
24
24
|
<button
|
|
25
25
|
type="button"
|
|
@@ -252,10 +252,8 @@ function DocSidebarItemLink({
|
|
|
252
252
|
onClick: onItemClick ? () => onItemClick(item) : undefined,
|
|
253
253
|
})}
|
|
254
254
|
{...props}>
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
{!isInternalUrl(href) && <IconExternalLink />}
|
|
258
|
-
</span>
|
|
255
|
+
{label}
|
|
256
|
+
{!isInternalUrl(href) && <IconExternalLink />}
|
|
259
257
|
</Link>
|
|
260
258
|
</li>
|
|
261
259
|
);
|
|
@@ -26,10 +26,8 @@ export default function FooterLinkItem({item}) {
|
|
|
26
26
|
to: toUrl,
|
|
27
27
|
})}
|
|
28
28
|
{...props}>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{href && !isInternalUrl(href) && <IconExternalLink />}
|
|
32
|
-
</span>
|
|
29
|
+
{label}
|
|
30
|
+
{href && !isInternalUrl(href) && <IconExternalLink />}
|
|
33
31
|
</Link>
|
|
34
32
|
);
|
|
35
33
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 Link from '@docusaurus/Link';
|
|
9
|
+
export default function MDXA(props) {
|
|
10
|
+
return <Link {...props} />;
|
|
11
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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, {isValidElement} from 'react';
|
|
8
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
9
|
+
export default function MDXCode(props) {
|
|
10
|
+
const inlineElements = [
|
|
11
|
+
'a',
|
|
12
|
+
'b',
|
|
13
|
+
'big',
|
|
14
|
+
'i',
|
|
15
|
+
'span',
|
|
16
|
+
'em',
|
|
17
|
+
'strong',
|
|
18
|
+
'sup',
|
|
19
|
+
'sub',
|
|
20
|
+
'small',
|
|
21
|
+
];
|
|
22
|
+
const shouldBeInline = React.Children.toArray(props.children).every(
|
|
23
|
+
(el) =>
|
|
24
|
+
(typeof el === 'string' && !el.includes('\n')) ||
|
|
25
|
+
(isValidElement(el) && inlineElements.includes(el.props.mdxType)),
|
|
26
|
+
);
|
|
27
|
+
return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 Details from '@theme/Details';
|
|
9
|
+
export default function MDXDetails(props) {
|
|
10
|
+
const items = React.Children.toArray(props.children); // Split summary item from the rest to pass it as a separate prop to the
|
|
11
|
+
// Details theme component
|
|
12
|
+
|
|
13
|
+
const summary = items.find((item) => item?.props?.mdxType === 'summary');
|
|
14
|
+
const children = <>{items.filter((item) => item !== summary)}</>;
|
|
15
|
+
return (
|
|
16
|
+
<Details {...props} summary={summary}>
|
|
17
|
+
{children}
|
|
18
|
+
</Details>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 Head from '@docusaurus/Head';
|
|
9
|
+
|
|
10
|
+
// MDX elements are wrapped through the MDX pragma. In some cases (notably usage
|
|
11
|
+
// with Head/Helmet) we need to unwrap those elements.
|
|
12
|
+
function unwrapMDXElement(element) {
|
|
13
|
+
if (element?.props?.mdxType && element?.props?.originalType) {
|
|
14
|
+
const {mdxType, originalType, ...newProps} = element.props;
|
|
15
|
+
return React.createElement(element.props.originalType, newProps);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return element;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function MDXHead(props) {
|
|
22
|
+
const unwrappedChildren = React.Children.map(props.children, (child) =>
|
|
23
|
+
unwrapMDXElement(child),
|
|
24
|
+
);
|
|
25
|
+
return <Head {...props}>{unwrappedChildren}</Head>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 Heading from '@theme/Heading';
|
|
9
|
+
export default function MDXHeading(props) {
|
|
10
|
+
return <Heading {...props} />;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 styles from './Img.module.css';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
|
|
11
|
+
function transformImgClassName(className) {
|
|
12
|
+
return clsx(className, styles.img);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function MDXImg(props) {
|
|
16
|
+
// eslint-disable-next-line jsx-a11y/alt-text
|
|
17
|
+
return <img {...props} className={transformImgClassName(props.className)} />;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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, {isValidElement} from 'react';
|
|
8
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
9
|
+
export default function MDXPre(props) {
|
|
10
|
+
return (
|
|
11
|
+
<CodeBlock // If this pre is created by a ``` fenced codeblock, unwrap the children
|
|
12
|
+
{...(isValidElement(props.children) &&
|
|
13
|
+
props.children.props.originalType === 'code'
|
|
14
|
+
? props.children?.props
|
|
15
|
+
: {...props})}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 styles from './Ul.module.css';
|
|
10
|
+
const containsClassListLocalClass = styles['contains-task-list'];
|
|
11
|
+
|
|
12
|
+
function transformUlClassName(className) {
|
|
13
|
+
return clsx(
|
|
14
|
+
className, // This class is set globally by GitHub/MDX
|
|
15
|
+
// We keep the global class, but apply scoped CSS
|
|
16
|
+
// See https://github.com/syntax-tree/mdast-util-to-hast/issues/28
|
|
17
|
+
className?.includes('contains-task-list') && containsClassListLocalClass,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function MDXUl(props) {
|
|
22
|
+
return <ul {...props} className={transformUlClassName(props.className)} />;
|
|
23
|
+
}
|
|
@@ -4,77 +4,28 @@
|
|
|
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
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import '
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function unwrapMDXElement(element) {
|
|
17
|
-
if (element?.props?.mdxType && element?.props?.originalType) {
|
|
18
|
-
const {mdxType, originalType, ...newProps} = element.props;
|
|
19
|
-
return React.createElement(element.props.originalType, newProps);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return element;
|
|
23
|
-
}
|
|
24
|
-
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import MDXHead from '@theme/MDXComponents/Head';
|
|
9
|
+
import MDXCode from '@theme/MDXComponents/Code';
|
|
10
|
+
import MDXA from '@theme/MDXComponents/A';
|
|
11
|
+
import MDXPre from '@theme/MDXComponents/Pre';
|
|
12
|
+
import MDXDetails from '@theme/MDXComponents/Details';
|
|
13
|
+
import MDXHeading from '@theme/MDXComponents/Heading';
|
|
14
|
+
import MDXUl from '@theme/MDXComponents/Ul';
|
|
15
|
+
import MDXImg from '@theme/MDXComponents/Img';
|
|
25
16
|
const MDXComponents = {
|
|
26
|
-
head:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
'em',
|
|
40
|
-
'strong',
|
|
41
|
-
'sup',
|
|
42
|
-
'sub',
|
|
43
|
-
'small',
|
|
44
|
-
];
|
|
45
|
-
const shouldBeInline = React.Children.toArray(props.children).every(
|
|
46
|
-
(el) =>
|
|
47
|
-
(typeof el === 'string' && !el.includes('\n')) ||
|
|
48
|
-
(isValidElement(el) && inlineElements.includes(el.props.mdxType)),
|
|
49
|
-
);
|
|
50
|
-
return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
|
|
51
|
-
},
|
|
52
|
-
a: (props) => <Link {...props} />,
|
|
53
|
-
pre: (props) => (
|
|
54
|
-
<CodeBlock // If this pre is created by a ``` fenced codeblock, unwrap the children
|
|
55
|
-
{...(isValidElement(props.children) &&
|
|
56
|
-
props.children.props.originalType === 'code'
|
|
57
|
-
? props.children?.props
|
|
58
|
-
: {...props})}
|
|
59
|
-
/>
|
|
60
|
-
),
|
|
61
|
-
details: (props) => {
|
|
62
|
-
const items = React.Children.toArray(props.children); // Split summary item from the rest to pass it as a separate prop to the
|
|
63
|
-
// Details theme component
|
|
64
|
-
|
|
65
|
-
const summary = items.find((item) => item?.props?.mdxType === 'summary');
|
|
66
|
-
const children = <>{items.filter((item) => item !== summary)}</>;
|
|
67
|
-
return (
|
|
68
|
-
<Details {...props} summary={summary}>
|
|
69
|
-
{children}
|
|
70
|
-
</Details>
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
h1: (props) => <Heading as="h1" {...props} />,
|
|
74
|
-
h2: (props) => <Heading as="h2" {...props} />,
|
|
75
|
-
h3: (props) => <Heading as="h3" {...props} />,
|
|
76
|
-
h4: (props) => <Heading as="h4" {...props} />,
|
|
77
|
-
h5: (props) => <Heading as="h5" {...props} />,
|
|
78
|
-
h6: (props) => <Heading as="h6" {...props} />,
|
|
17
|
+
head: MDXHead,
|
|
18
|
+
code: MDXCode,
|
|
19
|
+
a: MDXA,
|
|
20
|
+
pre: MDXPre,
|
|
21
|
+
details: MDXDetails,
|
|
22
|
+
ul: MDXUl,
|
|
23
|
+
img: MDXImg,
|
|
24
|
+
h1: (props) => <MDXHeading as="h1" {...props} />,
|
|
25
|
+
h2: (props) => <MDXHeading as="h2" {...props} />,
|
|
26
|
+
h3: (props) => <MDXHeading as="h3" {...props} />,
|
|
27
|
+
h4: (props) => <MDXHeading as="h4" {...props} />,
|
|
28
|
+
h5: (props) => <MDXHeading as="h5" {...props} />,
|
|
29
|
+
h6: (props) => <MDXHeading as="h6" {...props} />,
|
|
79
30
|
};
|
|
80
31
|
export default MDXComponents;
|
|
@@ -52,17 +52,15 @@ export default function NavbarNavLink({
|
|
|
52
52
|
: null),
|
|
53
53
|
})}
|
|
54
54
|
{...props}>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)}
|
|
65
|
-
</span>
|
|
55
|
+
{label}
|
|
56
|
+
{isExternalLink && (
|
|
57
|
+
<IconExternalLink
|
|
58
|
+
{...(isDropdownLink && {
|
|
59
|
+
width: 12,
|
|
60
|
+
height: 12,
|
|
61
|
+
})}
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
66
64
|
</Link>
|
|
67
65
|
);
|
|
68
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4767",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4767",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4767",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4767",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4767",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-4767",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-4767",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4767",
|
|
31
|
+
"@docusaurus/utils-common": "0.0.0-4767",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-4767",
|
|
33
33
|
"@mdx-js/react": "^1.6.22",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"rtlcss": "^3.5.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
46
|
-
"@docusaurus/types": "0.0.0-
|
|
45
|
+
"@docusaurus/module-type-aliases": "0.0.0-4767",
|
|
46
|
+
"@docusaurus/types": "0.0.0-4767",
|
|
47
47
|
"@types/mdx-js__react": "^1.5.5",
|
|
48
48
|
"@types/prismjs": "^1.26.0",
|
|
49
49
|
"@types/rtlcss": "^3.1.2",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=14"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "43401a74f943ccd154d080a713db58824191ff77"
|
|
63
63
|
}
|
package/src/getSwizzleConfig.ts
CHANGED
|
@@ -136,6 +136,68 @@ export default function getSwizzleConfig(): SwizzleConfig {
|
|
|
136
136
|
description:
|
|
137
137
|
'The MDX components to use for rendering MDX files. Meant to be ejected.',
|
|
138
138
|
},
|
|
139
|
+
'MDXComponents/A': {
|
|
140
|
+
actions: {
|
|
141
|
+
eject: 'safe',
|
|
142
|
+
wrap: 'safe',
|
|
143
|
+
},
|
|
144
|
+
description:
|
|
145
|
+
'The component used to render <a> tags and Markdown links in MDX',
|
|
146
|
+
},
|
|
147
|
+
'MDXComponents/Code': {
|
|
148
|
+
actions: {
|
|
149
|
+
eject: 'safe',
|
|
150
|
+
wrap: 'safe',
|
|
151
|
+
},
|
|
152
|
+
description:
|
|
153
|
+
'The component used to render <code> tags and Markdown code blocks in MDX',
|
|
154
|
+
},
|
|
155
|
+
'MDXComponents/Details': {
|
|
156
|
+
actions: {
|
|
157
|
+
eject: 'safe',
|
|
158
|
+
wrap: 'safe',
|
|
159
|
+
},
|
|
160
|
+
description: 'The component used to render <details> tags in MDX',
|
|
161
|
+
},
|
|
162
|
+
'MDXComponents/Head': {
|
|
163
|
+
actions: {
|
|
164
|
+
eject: 'forbidden',
|
|
165
|
+
wrap: 'forbidden',
|
|
166
|
+
},
|
|
167
|
+
description:
|
|
168
|
+
'Technical component used to assign metadata (generally for SEO purpose) to the current MDX document',
|
|
169
|
+
},
|
|
170
|
+
'MDXComponents/Heading': {
|
|
171
|
+
actions: {
|
|
172
|
+
eject: 'safe',
|
|
173
|
+
wrap: 'safe',
|
|
174
|
+
},
|
|
175
|
+
description:
|
|
176
|
+
'The component used to render heading tags (<h1>, <h2>...) and Markdown headings in MDX',
|
|
177
|
+
},
|
|
178
|
+
'MDXComponents/Img': {
|
|
179
|
+
actions: {
|
|
180
|
+
eject: 'safe',
|
|
181
|
+
wrap: 'safe',
|
|
182
|
+
},
|
|
183
|
+
description:
|
|
184
|
+
'The component used to render <img> tags and Markdown images in MDX',
|
|
185
|
+
},
|
|
186
|
+
'MDXComponents/Pre': {
|
|
187
|
+
actions: {
|
|
188
|
+
eject: 'safe',
|
|
189
|
+
wrap: 'safe',
|
|
190
|
+
},
|
|
191
|
+
description: 'The component used to render <pre> tags in MDX',
|
|
192
|
+
},
|
|
193
|
+
'MDXComponents/Ul': {
|
|
194
|
+
actions: {
|
|
195
|
+
eject: 'safe',
|
|
196
|
+
wrap: 'safe',
|
|
197
|
+
},
|
|
198
|
+
description:
|
|
199
|
+
'The component used to render <ul> tags and Markdown unordered lists in MDX',
|
|
200
|
+
},
|
|
139
201
|
MDXContent: {
|
|
140
202
|
actions: {
|
|
141
203
|
eject: 'safe',
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React, {useState} from 'react';
|
|
8
|
+
import React, {useCallback, useState, useRef, useEffect} from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import copy from 'copy-text-to-clipboard';
|
|
11
11
|
import {translate} from '@docusaurus/Translate';
|
|
@@ -15,14 +15,16 @@ import styles from './styles.module.css';
|
|
|
15
15
|
|
|
16
16
|
export default function CopyButton({code}: Props): JSX.Element {
|
|
17
17
|
const [isCopied, setIsCopied] = useState(false);
|
|
18
|
-
const
|
|
18
|
+
const copyTimeout = useRef<number | undefined>(undefined);
|
|
19
|
+
const handleCopyCode = useCallback(() => {
|
|
19
20
|
copy(code);
|
|
20
21
|
setIsCopied(true);
|
|
21
|
-
|
|
22
|
-
setTimeout(() => {
|
|
22
|
+
copyTimeout.current = window.setTimeout(() => {
|
|
23
23
|
setIsCopied(false);
|
|
24
|
-
},
|
|
25
|
-
};
|
|
24
|
+
}, 1000);
|
|
25
|
+
}, [code]);
|
|
26
|
+
|
|
27
|
+
useEffect(() => () => window.clearTimeout(copyTimeout.current), []);
|
|
26
28
|
|
|
27
29
|
return (
|
|
28
30
|
<button
|
|
@@ -269,10 +269,8 @@ function DocSidebarItemLink({
|
|
|
269
269
|
onClick: onItemClick ? () => onItemClick(item) : undefined,
|
|
270
270
|
})}
|
|
271
271
|
{...props}>
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
{!isInternalUrl(href) && <IconExternalLink />}
|
|
275
|
-
</span>
|
|
272
|
+
{label}
|
|
273
|
+
{!isInternalUrl(href) && <IconExternalLink />}
|
|
276
274
|
</Link>
|
|
277
275
|
</li>
|
|
278
276
|
);
|
|
@@ -29,10 +29,8 @@ export default function FooterLinkItem({item}: Props): JSX.Element {
|
|
|
29
29
|
to: toUrl,
|
|
30
30
|
})}
|
|
31
31
|
{...props}>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{href && !isInternalUrl(href) && <IconExternalLink />}
|
|
35
|
-
</span>
|
|
32
|
+
{label}
|
|
33
|
+
{href && !isInternalUrl(href) && <IconExternalLink />}
|
|
36
34
|
</Link>
|
|
37
35
|
);
|
|
38
36
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import Link from '@docusaurus/Link';
|
|
10
|
+
import type {Props} from '@theme/MDXComponents/A';
|
|
11
|
+
|
|
12
|
+
export default function MDXA(props: Props): JSX.Element {
|
|
13
|
+
return <Link {...props} />;
|
|
14
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 type {ComponentProps} from 'react';
|
|
9
|
+
import React, {isValidElement} from 'react';
|
|
10
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
11
|
+
import type {Props} from '@theme/MDXComponents/Code';
|
|
12
|
+
|
|
13
|
+
export default function MDXCode(props: Props): JSX.Element {
|
|
14
|
+
const inlineElements = [
|
|
15
|
+
'a',
|
|
16
|
+
'b',
|
|
17
|
+
'big',
|
|
18
|
+
'i',
|
|
19
|
+
'span',
|
|
20
|
+
'em',
|
|
21
|
+
'strong',
|
|
22
|
+
'sup',
|
|
23
|
+
'sub',
|
|
24
|
+
'small',
|
|
25
|
+
];
|
|
26
|
+
const shouldBeInline = React.Children.toArray(props.children).every(
|
|
27
|
+
(el) =>
|
|
28
|
+
(typeof el === 'string' && !el.includes('\n')) ||
|
|
29
|
+
(isValidElement(el) && inlineElements.includes(el.props.mdxType)),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return shouldBeInline ? (
|
|
33
|
+
<code {...props} />
|
|
34
|
+
) : (
|
|
35
|
+
<CodeBlock {...(props as ComponentProps<typeof CodeBlock>)} />
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 ComponentProps, type ReactElement} from 'react';
|
|
9
|
+
import Details from '@theme/Details';
|
|
10
|
+
import type {Props} from '@theme/MDXComponents/Details';
|
|
11
|
+
|
|
12
|
+
export default function MDXDetails(props: Props): JSX.Element {
|
|
13
|
+
const items = React.Children.toArray(props.children) as ReactElement[];
|
|
14
|
+
// Split summary item from the rest to pass it as a separate prop to the
|
|
15
|
+
// Details theme component
|
|
16
|
+
const summary: ReactElement<ComponentProps<'summary'>> = items.find(
|
|
17
|
+
(item) => item?.props?.mdxType === 'summary',
|
|
18
|
+
)!;
|
|
19
|
+
const children = <>{items.filter((item) => item !== summary)}</>;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Details {...props} summary={summary}>
|
|
23
|
+
{children}
|
|
24
|
+
</Details>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 ReactElement, type ComponentProps} from 'react';
|
|
9
|
+
import Head from '@docusaurus/Head';
|
|
10
|
+
import type {Props} from '@theme/MDXComponents/Head';
|
|
11
|
+
|
|
12
|
+
// MDX elements are wrapped through the MDX pragma. In some cases (notably usage
|
|
13
|
+
// with Head/Helmet) we need to unwrap those elements.
|
|
14
|
+
function unwrapMDXElement(element: ReactElement) {
|
|
15
|
+
if (element?.props?.mdxType && element?.props?.originalType) {
|
|
16
|
+
const {mdxType, originalType, ...newProps} = element.props;
|
|
17
|
+
return React.createElement(element.props.originalType, newProps);
|
|
18
|
+
}
|
|
19
|
+
return element;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function MDXHead(props: Props): JSX.Element {
|
|
23
|
+
const unwrappedChildren = React.Children.map(props.children, (child) =>
|
|
24
|
+
unwrapMDXElement(child as ReactElement),
|
|
25
|
+
);
|
|
26
|
+
return (
|
|
27
|
+
<Head {...(props as ComponentProps<typeof Head>)}>{unwrappedChildren}</Head>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import Heading from '@theme/Heading';
|
|
10
|
+
import type {Props} from '@theme/MDXComponents/Heading';
|
|
11
|
+
|
|
12
|
+
export default function MDXHeading(props: Props): JSX.Element {
|
|
13
|
+
return <Heading {...props} />;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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/MDXComponents/Img';
|
|
10
|
+
import styles from './Img.module.css';
|
|
11
|
+
import clsx from 'clsx';
|
|
12
|
+
|
|
13
|
+
function transformImgClassName(className?: string): string {
|
|
14
|
+
return clsx(className, styles.img);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function MDXImg(props: Props): JSX.Element {
|
|
18
|
+
// eslint-disable-next-line jsx-a11y/alt-text
|
|
19
|
+
return <img {...props} className={transformImgClassName(props.className)} />;
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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, {isValidElement} from 'react';
|
|
9
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
10
|
+
|
|
11
|
+
export default function MDXPre(props: any) {
|
|
12
|
+
return (
|
|
13
|
+
<CodeBlock
|
|
14
|
+
// If this pre is created by a ``` fenced codeblock, unwrap the children
|
|
15
|
+
{...(isValidElement(props.children) &&
|
|
16
|
+
props.children.props.originalType === 'code'
|
|
17
|
+
? props.children?.props
|
|
18
|
+
: {...props})}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
import type {Props} from '@theme/MDXComponents/Ul';
|
|
11
|
+
|
|
12
|
+
import styles from './Ul.module.css';
|
|
13
|
+
|
|
14
|
+
const containsClassListLocalClass = styles['contains-task-list'];
|
|
15
|
+
|
|
16
|
+
function transformUlClassName(className?: string): string {
|
|
17
|
+
return clsx(
|
|
18
|
+
className,
|
|
19
|
+
// This class is set globally by GitHub/MDX
|
|
20
|
+
// We keep the global class, but apply scoped CSS
|
|
21
|
+
// See https://github.com/syntax-tree/mdast-util-to-hast/issues/28
|
|
22
|
+
className?.includes('contains-task-list') && containsClassListLocalClass,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function MDXUl(props: Props): JSX.Element {
|
|
27
|
+
return <ul {...props} className={transformUlClassName(props.className)} />;
|
|
28
|
+
}
|
|
@@ -5,89 +5,32 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import Details from '@theme/Details';
|
|
18
|
-
import type {MDXComponentsObject} from '@theme/MDXComponents';
|
|
19
|
-
|
|
20
|
-
import './styles.css';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import MDXHead from '@theme/MDXComponents/Head';
|
|
10
|
+
import MDXCode from '@theme/MDXComponents/Code';
|
|
11
|
+
import MDXA from '@theme/MDXComponents/A';
|
|
12
|
+
import MDXPre from '@theme/MDXComponents/Pre';
|
|
13
|
+
import MDXDetails from '@theme/MDXComponents/Details';
|
|
14
|
+
import MDXHeading from '@theme/MDXComponents/Heading';
|
|
15
|
+
import MDXUl from '@theme/MDXComponents/Ul';
|
|
16
|
+
import MDXImg from '@theme/MDXComponents/Img';
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
// with Head/Helmet) we need to unwrap those elements.
|
|
24
|
-
function unwrapMDXElement(element: ReactElement) {
|
|
25
|
-
if (element?.props?.mdxType && element?.props?.originalType) {
|
|
26
|
-
const {mdxType, originalType, ...newProps} = element.props;
|
|
27
|
-
return React.createElement(element.props.originalType, newProps);
|
|
28
|
-
}
|
|
29
|
-
return element;
|
|
30
|
-
}
|
|
18
|
+
import type {MDXComponentsObject} from '@theme/MDXComponents';
|
|
31
19
|
|
|
32
20
|
const MDXComponents: MDXComponentsObject = {
|
|
33
|
-
head:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'em',
|
|
47
|
-
'strong',
|
|
48
|
-
'sup',
|
|
49
|
-
'sub',
|
|
50
|
-
'small',
|
|
51
|
-
];
|
|
52
|
-
const shouldBeInline = React.Children.toArray(props.children).every(
|
|
53
|
-
(el) =>
|
|
54
|
-
(typeof el === 'string' && !el.includes('\n')) ||
|
|
55
|
-
(isValidElement(el) && inlineElements.includes(el.props.mdxType)),
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
|
|
59
|
-
},
|
|
60
|
-
a: (props) => <Link {...props} />,
|
|
61
|
-
pre: (props) => (
|
|
62
|
-
<CodeBlock
|
|
63
|
-
// If this pre is created by a ``` fenced codeblock, unwrap the children
|
|
64
|
-
{...(isValidElement(props.children) &&
|
|
65
|
-
props.children.props.originalType === 'code'
|
|
66
|
-
? props.children?.props
|
|
67
|
-
: {...props})}
|
|
68
|
-
/>
|
|
69
|
-
),
|
|
70
|
-
details: (props): JSX.Element => {
|
|
71
|
-
const items = React.Children.toArray(props.children) as ReactElement[];
|
|
72
|
-
// Split summary item from the rest to pass it as a separate prop to the
|
|
73
|
-
// Details theme component
|
|
74
|
-
const summary: ReactElement<ComponentProps<'summary'>> = items.find(
|
|
75
|
-
(item) => item?.props?.mdxType === 'summary',
|
|
76
|
-
)!;
|
|
77
|
-
const children = <>{items.filter((item) => item !== summary)}</>;
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<Details {...props} summary={summary}>
|
|
81
|
-
{children}
|
|
82
|
-
</Details>
|
|
83
|
-
);
|
|
84
|
-
},
|
|
85
|
-
h1: (props) => <Heading as="h1" {...props} />,
|
|
86
|
-
h2: (props) => <Heading as="h2" {...props} />,
|
|
87
|
-
h3: (props) => <Heading as="h3" {...props} />,
|
|
88
|
-
h4: (props) => <Heading as="h4" {...props} />,
|
|
89
|
-
h5: (props) => <Heading as="h5" {...props} />,
|
|
90
|
-
h6: (props) => <Heading as="h6" {...props} />,
|
|
21
|
+
head: MDXHead,
|
|
22
|
+
code: MDXCode,
|
|
23
|
+
a: MDXA,
|
|
24
|
+
pre: MDXPre,
|
|
25
|
+
details: MDXDetails,
|
|
26
|
+
ul: MDXUl,
|
|
27
|
+
img: MDXImg,
|
|
28
|
+
h1: (props) => <MDXHeading as="h1" {...props} />,
|
|
29
|
+
h2: (props) => <MDXHeading as="h2" {...props} />,
|
|
30
|
+
h3: (props) => <MDXHeading as="h3" {...props} />,
|
|
31
|
+
h4: (props) => <MDXHeading as="h4" {...props} />,
|
|
32
|
+
h5: (props) => <MDXHeading as="h5" {...props} />,
|
|
33
|
+
h6: (props) => <MDXHeading as="h6" {...props} />,
|
|
91
34
|
};
|
|
92
35
|
|
|
93
36
|
export default MDXComponents;
|
|
@@ -55,12 +55,10 @@ export default function NavbarNavLink({
|
|
|
55
55
|
: null),
|
|
56
56
|
})}
|
|
57
57
|
{...props}>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
)}
|
|
63
|
-
</span>
|
|
58
|
+
{label}
|
|
59
|
+
{isExternalLink && (
|
|
60
|
+
<IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
|
|
61
|
+
)}
|
|
64
62
|
</Link>
|
|
65
63
|
);
|
|
66
64
|
}
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -417,24 +417,97 @@ declare module '@theme/SkipToContent' {
|
|
|
417
417
|
export default function SkipToContent(): JSX.Element;
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
declare module '@theme/MDXComponents' {
|
|
420
|
+
declare module '@theme/MDXComponents/A' {
|
|
421
|
+
import type {ComponentProps} from 'react';
|
|
422
|
+
|
|
423
|
+
export interface Props extends ComponentProps<'a'> {}
|
|
424
|
+
|
|
425
|
+
export default function MDXA(props: Props): JSX.Element;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
declare module '@theme/MDXComponents/Code' {
|
|
429
|
+
import type {ComponentProps} from 'react';
|
|
430
|
+
|
|
431
|
+
export interface Props extends ComponentProps<'code'> {}
|
|
432
|
+
|
|
433
|
+
export default function MDXCode(props: Props): JSX.Element;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
declare module '@theme/MDXComponents/Details' {
|
|
421
437
|
import type {ComponentProps} from 'react';
|
|
422
|
-
|
|
423
|
-
|
|
438
|
+
|
|
439
|
+
export interface Props extends ComponentProps<'details'> {}
|
|
440
|
+
|
|
441
|
+
export default function MDXDetails(props: Props): JSX.Element;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
declare module '@theme/MDXComponents/Ul' {
|
|
445
|
+
import type {ComponentProps} from 'react';
|
|
446
|
+
|
|
447
|
+
export interface Props extends ComponentProps<'ul'> {}
|
|
448
|
+
|
|
449
|
+
export default function MDXUl(props: Props): JSX.Element;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
declare module '@theme/MDXComponents/Img' {
|
|
453
|
+
import type {ComponentProps} from 'react';
|
|
454
|
+
|
|
455
|
+
export interface Props extends ComponentProps<'img'> {}
|
|
456
|
+
|
|
457
|
+
export default function MDXImg(props: Props): JSX.Element;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
declare module '@theme/MDXComponents/Head' {
|
|
461
|
+
import type {ComponentProps} from 'react';
|
|
462
|
+
|
|
463
|
+
export interface Props extends ComponentProps<'head'> {}
|
|
464
|
+
|
|
465
|
+
export default function MDXHead(props: Props): JSX.Element;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
declare module '@theme/MDXComponents/Heading' {
|
|
469
|
+
import type {ComponentProps} from 'react';
|
|
470
|
+
import type Heading from '@theme/Heading';
|
|
471
|
+
|
|
472
|
+
export interface Props extends ComponentProps<typeof Heading> {}
|
|
473
|
+
|
|
474
|
+
export default function MDXHeading(props: Props): JSX.Element;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
declare module '@theme/MDXComponents/Pre' {
|
|
478
|
+
import type {ComponentProps} from 'react';
|
|
479
|
+
|
|
480
|
+
export interface Props extends ComponentProps<'pre'> {}
|
|
481
|
+
|
|
482
|
+
export default function MDXPre(props: Props): JSX.Element;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
declare module '@theme/MDXComponents' {
|
|
486
|
+
import type {ComponentType, ComponentProps} from 'react';
|
|
487
|
+
|
|
488
|
+
import type MDXHead from '@theme/MDXComponents/Head';
|
|
489
|
+
import type MDXCode from '@theme/MDXComponents/Code';
|
|
490
|
+
import type MDXA from '@theme/MDXComponents/A';
|
|
491
|
+
import type MDXPre from '@theme/MDXComponents/Pre';
|
|
492
|
+
import type MDXDetails from '@theme/MDXComponents/Details';
|
|
493
|
+
import type MDXUl from '@theme/MDXComponents/Ul';
|
|
494
|
+
import type MDXImg from '@theme/MDXComponents/Img';
|
|
424
495
|
|
|
425
496
|
export type MDXComponentsObject = {
|
|
426
|
-
readonly head: typeof
|
|
427
|
-
readonly code: typeof
|
|
428
|
-
readonly a:
|
|
429
|
-
readonly pre: typeof
|
|
430
|
-
readonly details:
|
|
497
|
+
readonly head: typeof MDXHead;
|
|
498
|
+
readonly code: typeof MDXCode;
|
|
499
|
+
readonly a: typeof MDXA;
|
|
500
|
+
readonly pre: typeof MDXPre;
|
|
501
|
+
readonly details: typeof MDXDetails;
|
|
502
|
+
readonly ul: typeof MDXUl;
|
|
503
|
+
readonly img: typeof MDXImg;
|
|
431
504
|
readonly h1: (props: ComponentProps<'h1'>) => JSX.Element;
|
|
432
505
|
readonly h2: (props: ComponentProps<'h2'>) => JSX.Element;
|
|
433
506
|
readonly h3: (props: ComponentProps<'h3'>) => JSX.Element;
|
|
434
507
|
readonly h4: (props: ComponentProps<'h4'>) => JSX.Element;
|
|
435
508
|
readonly h5: (props: ComponentProps<'h5'>) => JSX.Element;
|
|
436
509
|
readonly h6: (props: ComponentProps<'h6'>) => JSX.Element;
|
|
437
|
-
}
|
|
510
|
+
} & Record<string, ComponentType<unknown>>;
|
|
438
511
|
|
|
439
512
|
const MDXComponents: MDXComponentsObject;
|
|
440
513
|
export default MDXComponents;
|