@docusaurus/theme-classic 3.0.1 → 3.1.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/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/package.json +14 -14
- 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-classic.d.ts +8 -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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
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.0
|
|
24
|
-
"@docusaurus/mdx-loader": "3.0
|
|
25
|
-
"@docusaurus/module-type-aliases": "3.0
|
|
26
|
-
"@docusaurus/plugin-content-blog": "3.0
|
|
27
|
-
"@docusaurus/plugin-content-docs": "3.0
|
|
28
|
-
"@docusaurus/plugin-content-pages": "3.0
|
|
29
|
-
"@docusaurus/theme-common": "3.0
|
|
30
|
-
"@docusaurus/theme-translations": "3.0
|
|
31
|
-
"@docusaurus/types": "3.0
|
|
32
|
-
"@docusaurus/utils": "3.0
|
|
33
|
-
"@docusaurus/utils-common": "3.0
|
|
34
|
-
"@docusaurus/utils-validation": "3.0
|
|
23
|
+
"@docusaurus/core": "3.1.0",
|
|
24
|
+
"@docusaurus/mdx-loader": "3.1.0",
|
|
25
|
+
"@docusaurus/module-type-aliases": "3.1.0",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "3.1.0",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "3.1.0",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "3.1.0",
|
|
29
|
+
"@docusaurus/theme-common": "3.1.0",
|
|
30
|
+
"@docusaurus/theme-translations": "3.1.0",
|
|
31
|
+
"@docusaurus/types": "3.1.0",
|
|
32
|
+
"@docusaurus/utils": "3.1.0",
|
|
33
|
+
"@docusaurus/utils-common": "3.1.0",
|
|
34
|
+
"@docusaurus/utils-validation": "3.1.0",
|
|
35
35
|
"@mdx-js/react": "^3.0.0",
|
|
36
36
|
"clsx": "^2.0.0",
|
|
37
37
|
"copy-text-to-clipboard": "^3.2.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=18.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "a5e675821f0e8b70b591fcebf19fd60a70d55548"
|
|
66
66
|
}
|
|
@@ -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
|
);
|
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;
|