@docusaurus/theme-classic 3.0.0 → 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.
@@ -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
- const shouldBeInline = React.Children.toArray(props.children).every(
11
- (el) => typeof el === 'string' && !el.includes('\n'),
21
+ return shouldBeInline(props) ? (
22
+ <CodeInline {...props} />
23
+ ) : (
24
+ <CodeBlock {...props} />
12
25
  );
13
- return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
14
26
  }
@@ -9,8 +9,15 @@
9
9
  Workaround to avoid rendering empty search container
10
10
  See https://github.com/facebook/docusaurus/pull/9385
11
11
  */
12
- .navbarSearchContainer:not(:has(> *)) {
13
- display: none;
12
+ /*
13
+ TODO temporary @supports check, remove before 2025
14
+ only needed for Firefox < 121
15
+ see https://github.com/facebook/docusaurus/issues/9527#issuecomment-1805272379
16
+ */
17
+ @supports selector(:has(*)) {
18
+ .navbarSearchContainer:not(:has(> *)) {
19
+ display: none;
20
+ }
14
21
  }
15
22
 
16
23
  @media (max-width: 996px) {
@@ -14,6 +14,7 @@ import {
14
14
  import {isSamePath, useLocalPathname} from '@docusaurus/theme-common/internal';
15
15
  import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
16
16
  import NavbarItem from '@theme/NavbarItem';
17
+ import styles from './styles.module.css';
17
18
  function isItemActive(item, localPathname) {
18
19
  if (isSamePath(item.to, localPathname)) {
19
20
  return true;
@@ -116,6 +117,7 @@ function DropdownNavbarItemMobile({
116
117
  <NavbarNavLink
117
118
  role="button"
118
119
  className={clsx(
120
+ styles.dropdownNavbarItemMobile,
119
121
  'menu__link menu__link--sublist menu__link--sublist-caret',
120
122
  className,
121
123
  )}
@@ -0,0 +1,10 @@
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
+ .dropdownNavbarItemMobile {
9
+ cursor: pointer;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "3.0.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,26 +20,26 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "3.0.0",
24
- "@docusaurus/mdx-loader": "3.0.0",
25
- "@docusaurus/module-type-aliases": "3.0.0",
26
- "@docusaurus/plugin-content-blog": "3.0.0",
27
- "@docusaurus/plugin-content-docs": "3.0.0",
28
- "@docusaurus/plugin-content-pages": "3.0.0",
29
- "@docusaurus/theme-common": "3.0.0",
30
- "@docusaurus/theme-translations": "3.0.0",
31
- "@docusaurus/types": "3.0.0",
32
- "@docusaurus/utils": "3.0.0",
33
- "@docusaurus/utils-common": "3.0.0",
34
- "@docusaurus/utils-validation": "3.0.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
- "clsx": "^1.2.1",
36
+ "clsx": "^2.0.0",
37
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
41
  "postcss": "^8.4.26",
42
- "prism-react-renderer": "^2.1.0",
42
+ "prism-react-renderer": "^2.3.0",
43
43
  "prismjs": "^1.29.0",
44
44
  "react-router-dom": "^5.3.4",
45
45
  "rtlcss": "^4.1.0",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=18.0"
64
64
  },
65
- "gitHead": "ca8b4638c47119d38838656c4a11ee3a5e7ba6f2"
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
- export default function MDXCode(props: Props): JSX.Element {
14
- const shouldBeInline = React.Children.toArray(props.children).every(
15
- (el) => typeof el === 'string' && !el.includes('\n'),
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
- return shouldBeInline ? (
19
- <code {...props} />
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
  );
@@ -9,8 +9,15 @@
9
9
  Workaround to avoid rendering empty search container
10
10
  See https://github.com/facebook/docusaurus/pull/9385
11
11
  */
12
- .navbarSearchContainer:not(:has(> *)) {
13
- display: none;
12
+ /*
13
+ TODO temporary @supports check, remove before 2025
14
+ only needed for Firefox < 121
15
+ see https://github.com/facebook/docusaurus/issues/9527#issuecomment-1805272379
16
+ */
17
+ @supports selector(:has(*)) {
18
+ .navbarSearchContainer:not(:has(> *)) {
19
+ display: none;
20
+ }
14
21
  }
15
22
 
16
23
  @media (max-width: 996px) {
@@ -19,6 +19,7 @@ import type {
19
19
  DesktopOrMobileNavBarItemProps,
20
20
  Props,
21
21
  } from '@theme/NavbarItem/DropdownNavbarItem';
22
+ import styles from './styles.module.css';
22
23
 
23
24
  function isItemActive(
24
25
  item: LinkLikeNavbarItemProps,
@@ -143,6 +144,7 @@ function DropdownNavbarItemMobile({
143
144
  <NavbarNavLink
144
145
  role="button"
145
146
  className={clsx(
147
+ styles.dropdownNavbarItemMobile,
146
148
  'menu__link menu__link--sublist menu__link--sublist-caret',
147
149
  className,
148
150
  )}
@@ -0,0 +1,10 @@
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
+ .dropdownNavbarItemMobile {
9
+ cursor: pointer;
10
+ }
@@ -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;