@docusaurus/theme-classic 0.0.0-5553 → 0.0.0-5556

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.
@@ -290,13 +290,6 @@ function getSwizzleConfig() {
290
290
  },
291
291
  description: 'The component used to render <details> tags in MDX',
292
292
  },
293
- 'MDXComponents/Head': {
294
- actions: {
295
- eject: 'forbidden',
296
- wrap: 'forbidden',
297
- },
298
- description: 'Technical component used to assign metadata (generally for SEO purpose) to the current MDX document',
299
- },
300
293
  'MDXComponents/Heading': {
301
294
  actions: {
302
295
  eject: 'safe',
package/lib/options.js CHANGED
@@ -174,6 +174,7 @@ const LocaleDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
174
174
  type: utils_validation_1.Joi.string().equal('localeDropdown').required(),
175
175
  dropdownItemsBefore: utils_validation_1.Joi.array().items(DropdownSubitemSchema).default([]),
176
176
  dropdownItemsAfter: utils_validation_1.Joi.array().items(DropdownSubitemSchema).default([]),
177
+ queryString: utils_validation_1.Joi.string(),
177
178
  });
178
179
  const SearchItemSchema = utils_validation_1.Joi.object({
179
180
  type: utils_validation_1.Joi.string().equal('search').required(),
@@ -4,45 +4,11 @@
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, {isValidElement} from 'react';
7
+ import React from 'react';
8
8
  import CodeBlock from '@theme/CodeBlock';
9
9
  export default function MDXCode(props) {
10
- const inlineElements = [
11
- 'a',
12
- 'abbr',
13
- 'b',
14
- 'br',
15
- 'button',
16
- 'cite',
17
- 'code',
18
- 'del',
19
- 'dfn',
20
- 'em',
21
- 'i',
22
- 'img',
23
- 'input',
24
- 'ins',
25
- 'kbd',
26
- 'label',
27
- 'object',
28
- 'output',
29
- 'q',
30
- 'ruby',
31
- 's',
32
- 'small',
33
- 'span',
34
- 'strong',
35
- 'sub',
36
- 'sup',
37
- 'time',
38
- 'u',
39
- 'var',
40
- 'wbr',
41
- ];
42
10
  const shouldBeInline = React.Children.toArray(props.children).every(
43
- (el) =>
44
- (typeof el === 'string' && !el.includes('\n')) ||
45
- (isValidElement(el) && inlineElements.includes(el.props?.mdxType)),
11
+ (el) => typeof el === 'string' && !el.includes('\n'),
46
12
  );
47
13
  return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
48
14
  }
@@ -11,7 +11,7 @@ export default function MDXDetails(props) {
11
11
  // Split summary item from the rest to pass it as a separate prop to the
12
12
  // Details theme component
13
13
  const summary = items.find(
14
- (item) => React.isValidElement(item) && item.props?.mdxType === 'summary',
14
+ (item) => React.isValidElement(item) && item.type === 'summary',
15
15
  );
16
16
  const children = <>{items.filter((item) => item !== summary)}</>;
17
17
  return (
@@ -4,6 +4,6 @@
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
- /// <reference types="react" />
7
+ import { type ReactNode } from 'react';
8
8
  import type { Props } from '@theme/MDXComponents/Pre';
9
- export default function MDXPre(props: Props): JSX.Element;
9
+ export default function MDXPre(props: Props): ReactNode | undefined;
@@ -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, {isValidElement} from 'react';
8
- import CodeBlock from '@theme/CodeBlock';
7
+ import React from 'react';
9
8
  export default function MDXPre(props) {
10
- return (
11
- <CodeBlock
12
- // If this pre is created by a ``` fenced codeblock, unwrap the children
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
  }
@@ -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 MDXHead from '@theme/MDXComponents/Head';
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,11 @@ 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
- head: MDXHead,
19
+ Head,
20
+ Details: MDXDetails,
20
21
  code: MDXCode,
21
22
  a: MDXA,
22
23
  pre: MDXPre,
23
- details: MDXDetails,
24
24
  ul: MDXUl,
25
25
  img: MDXImg,
26
26
  h1: (props) => <MDXHeading as="h1" {...props} />,
@@ -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
+ // @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
8
9
  import {MDXProvider} from '@mdx-js/react';
9
10
  import MDXComponents from '@theme/MDXComponents';
10
11
  export default function MDXContent({children}) {
@@ -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,
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-5553",
3
+ "version": "0.0.0-5556",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -20,19 +20,19 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "0.0.0-5553",
24
- "@docusaurus/mdx-loader": "0.0.0-5553",
25
- "@docusaurus/module-type-aliases": "0.0.0-5553",
26
- "@docusaurus/plugin-content-blog": "0.0.0-5553",
27
- "@docusaurus/plugin-content-docs": "0.0.0-5553",
28
- "@docusaurus/plugin-content-pages": "0.0.0-5553",
29
- "@docusaurus/theme-common": "0.0.0-5553",
30
- "@docusaurus/theme-translations": "0.0.0-5553",
31
- "@docusaurus/types": "0.0.0-5553",
32
- "@docusaurus/utils": "0.0.0-5553",
33
- "@docusaurus/utils-common": "0.0.0-5553",
34
- "@docusaurus/utils-validation": "0.0.0-5553",
35
- "@mdx-js/react": "^1.6.22",
23
+ "@docusaurus/core": "0.0.0-5556",
24
+ "@docusaurus/mdx-loader": "0.0.0-5556",
25
+ "@docusaurus/module-type-aliases": "0.0.0-5556",
26
+ "@docusaurus/plugin-content-blog": "0.0.0-5556",
27
+ "@docusaurus/plugin-content-docs": "0.0.0-5556",
28
+ "@docusaurus/plugin-content-pages": "0.0.0-5556",
29
+ "@docusaurus/theme-common": "0.0.0-5556",
30
+ "@docusaurus/theme-translations": "0.0.0-5556",
31
+ "@docusaurus/types": "0.0.0-5556",
32
+ "@docusaurus/utils": "0.0.0-5556",
33
+ "@docusaurus/utils-common": "0.0.0-5556",
34
+ "@docusaurus/utils-validation": "0.0.0-5556",
35
+ "@mdx-js/react": "^2.1.5",
36
36
  "clsx": "^1.2.1",
37
37
  "copy-text-to-clipboard": "^3.0.1",
38
38
  "infima": "0.2.0-alpha.43",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=16.14"
64
64
  },
65
- "gitHead": "97ccda99d18853f12b12f3732ef1f273a5c94af1"
65
+ "gitHead": "af59fefe36b8f8cd02bf854d5f41906e631134d6"
66
66
  }
@@ -312,14 +312,6 @@ export default function getSwizzleConfig(): SwizzleConfig {
312
312
  },
313
313
  description: 'The component used to render <details> tags in MDX',
314
314
  },
315
- 'MDXComponents/Head': {
316
- actions: {
317
- eject: 'forbidden',
318
- wrap: 'forbidden',
319
- },
320
- description:
321
- 'Technical component used to assign metadata (generally for SEO purpose) to the current MDX document',
322
- },
323
315
  'MDXComponents/Heading': {
324
316
  actions: {
325
317
  eject: 'safe',
package/src/options.ts CHANGED
@@ -200,6 +200,7 @@ const LocaleDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
200
200
  type: Joi.string().equal('localeDropdown').required(),
201
201
  dropdownItemsBefore: Joi.array().items(DropdownSubitemSchema).default([]),
202
202
  dropdownItemsAfter: Joi.array().items(DropdownSubitemSchema).default([]),
203
+ queryString: Joi.string(),
203
204
  });
204
205
 
205
206
  const SearchItemSchema = Joi.object({
@@ -6,50 +6,13 @@
6
6
  */
7
7
 
8
8
  import type {ComponentProps} from 'react';
9
- import React, {isValidElement} from 'react';
9
+ import React from 'react';
10
10
  import CodeBlock from '@theme/CodeBlock';
11
11
  import type {Props} from '@theme/MDXComponents/Code';
12
12
 
13
13
  export default function MDXCode(props: Props): JSX.Element {
14
- const inlineElements: (string | undefined)[] = [
15
- 'a',
16
- 'abbr',
17
- 'b',
18
- 'br',
19
- 'button',
20
- 'cite',
21
- 'code',
22
- 'del',
23
- 'dfn',
24
- 'em',
25
- 'i',
26
- 'img',
27
- 'input',
28
- 'ins',
29
- 'kbd',
30
- 'label',
31
- 'object',
32
- 'output',
33
- 'q',
34
- 'ruby',
35
- 's',
36
- 'small',
37
- 'span',
38
- 'strong',
39
- 'sub',
40
- 'sup',
41
- 'time',
42
- 'u',
43
- 'var',
44
- 'wbr',
45
- ];
46
14
  const shouldBeInline = React.Children.toArray(props.children).every(
47
- (el) =>
48
- (typeof el === 'string' && !el.includes('\n')) ||
49
- (isValidElement(el) &&
50
- inlineElements.includes(
51
- (el.props as {mdxType: string} | null)?.mdxType,
52
- )),
15
+ (el) => typeof el === 'string' && !el.includes('\n'),
53
16
  );
54
17
 
55
18
  return shouldBeInline ? (
@@ -15,8 +15,7 @@ export default function MDXDetails(props: Props): JSX.Element {
15
15
  // Details theme component
16
16
  const summary = items.find(
17
17
  (item): item is ReactElement<ComponentProps<'summary'>> =>
18
- React.isValidElement(item) &&
19
- (item.props as {mdxType: string} | null)?.mdxType === 'summary',
18
+ React.isValidElement(item) && item.type === 'summary',
20
19
  );
21
20
  const children = <>{items.filter((item) => item !== summary)}</>;
22
21
 
@@ -5,19 +5,11 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {isValidElement} from 'react';
9
- import CodeBlock from '@theme/CodeBlock';
8
+ import React, {type ReactNode} from 'react';
10
9
  import type {Props} from '@theme/MDXComponents/Pre';
11
10
 
12
- export default function MDXPre(props: Props): JSX.Element {
13
- return (
14
- <CodeBlock
15
- // If this pre is created by a ``` fenced codeblock, unwrap the children
16
- {...(isValidElement(props.children) &&
17
- (props.children.props as {originalType: string} | null)?.originalType ===
18
- 'code'
19
- ? props.children.props
20
- : {...props})}
21
- />
22
- );
11
+ export default function MDXPre(props: Props): ReactNode | undefined {
12
+ // With MDX 2, this element is only used for fenced code blocks
13
+ // It always receives a MDXComponents/Code as children
14
+ return <>{props.children}</>;
23
15
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import MDXHead from '@theme/MDXComponents/Head';
9
+ import Head from '@docusaurus/Head';
10
10
  import MDXCode from '@theme/MDXComponents/Code';
11
11
  import MDXA from '@theme/MDXComponents/A';
12
12
  import MDXPre from '@theme/MDXComponents/Pre';
@@ -20,11 +20,11 @@ import Mermaid from '@theme/Mermaid';
20
20
  import type {MDXComponentsObject} from '@theme/MDXComponents';
21
21
 
22
22
  const MDXComponents: MDXComponentsObject = {
23
- head: MDXHead,
23
+ Head,
24
+ Details: MDXDetails,
24
25
  code: MDXCode,
25
26
  a: MDXA,
26
27
  pre: MDXPre,
27
- details: MDXDetails,
28
28
  ul: MDXUl,
29
29
  img: MDXImg,
30
30
  h1: (props) => <MDXHeading as="h1" {...props} />,
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
+ // @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
9
10
  import {MDXProvider} from '@mdx-js/react';
10
11
  import MDXComponents from '@theme/MDXComponents';
11
12
  import type {Props} from '@theme/MDXContent';
@@ -21,6 +21,7 @@ export default function LocaleDropdownNavbarItem({
21
21
  mobile,
22
22
  dropdownItemsBefore,
23
23
  dropdownItemsAfter,
24
+ queryString = '',
24
25
  ...props
25
26
  }: Props): JSX.Element {
26
27
  const {
@@ -35,7 +36,7 @@ export default function LocaleDropdownNavbarItem({
35
36
  fullyQualified: false,
36
37
  })}`;
37
38
  // preserve ?search#hash suffix on locale switches
38
- const to = `${baseTo}${search}${hash}`;
39
+ const to = `${baseTo}${search}${hash}${queryString}`;
39
40
  return {
40
41
  label: localeConfigs[locale]!.label,
41
42
  lang: localeConfigs[locale]!.htmlLang,
@@ -10,6 +10,7 @@ import clsx from 'clsx';
10
10
  import {
11
11
  useScrollPositionBlocker,
12
12
  useTabs,
13
+ sanitizeTabsChildren,
13
14
  type TabItemProps,
14
15
  } from '@docusaurus/theme-common/internal';
15
16
  import useIsBrowser from '@docusaurus/useIsBrowser';
@@ -152,7 +153,8 @@ export default function Tabs(props: Props): JSX.Element {
152
153
  // Remount tabs after hydration
153
154
  // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
154
155
  key={String(isBrowser)}
155
- {...props}
156
- />
156
+ {...props}>
157
+ {sanitizeTabsChildren(props.children)}
158
+ </TabsComponent>
157
159
  );
158
160
  }
@@ -861,14 +861,6 @@ declare module '@theme/MDXComponents/Img' {
861
861
  export default function MDXImg(props: Props): JSX.Element;
862
862
  }
863
863
 
864
- declare module '@theme/MDXComponents/Head' {
865
- import type {ComponentProps} from 'react';
866
-
867
- export interface Props extends ComponentProps<'head'> {}
868
-
869
- export default function MDXHead(props: Props): JSX.Element;
870
- }
871
-
872
864
  declare module '@theme/MDXComponents/Heading' {
873
865
  import type {ComponentProps} from 'react';
874
866
  import type Heading from '@theme/Heading';
@@ -889,7 +881,6 @@ declare module '@theme/MDXComponents/Pre' {
889
881
  declare module '@theme/MDXComponents' {
890
882
  import type {ComponentType, ComponentProps} from 'react';
891
883
 
892
- import type MDXHead from '@theme/MDXComponents/Head';
893
884
  import type MDXCode from '@theme/MDXComponents/Code';
894
885
  import type MDXA from '@theme/MDXComponents/A';
895
886
  import type MDXPre from '@theme/MDXComponents/Pre';
@@ -898,13 +889,14 @@ declare module '@theme/MDXComponents' {
898
889
  import type MDXImg from '@theme/MDXComponents/Img';
899
890
  import type Admonition from '@theme/Admonition';
900
891
  import type Mermaid from '@theme/Mermaid';
892
+ import type Head from '@docusaurus/Head';
901
893
 
902
894
  export type MDXComponentsObject = {
903
- readonly head: typeof MDXHead;
895
+ readonly Head: typeof Head;
896
+ readonly Details: typeof MDXDetails;
904
897
  readonly code: typeof MDXCode;
905
898
  readonly a: typeof MDXA;
906
899
  readonly pre: typeof MDXPre;
907
- readonly details: typeof MDXDetails;
908
900
  readonly ul: typeof MDXUl;
909
901
  readonly img: typeof MDXImg;
910
902
  readonly h1: (props: ComponentProps<'h1'>) => JSX.Element;
@@ -1072,6 +1064,7 @@ declare module '@theme/NavbarItem/LocaleDropdownNavbarItem' {
1072
1064
  export interface Props extends DropdownNavbarItemProps {
1073
1065
  readonly dropdownItemsBefore: LinkLikeNavbarItemProps[];
1074
1066
  readonly dropdownItemsAfter: LinkLikeNavbarItemProps[];
1067
+ readonly queryString?: string;
1075
1068
  }
1076
1069
 
1077
1070
  export default function LocaleDropdownNavbarItem(props: Props): JSX.Element;
@@ -1,9 +0,0 @@
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/MDXComponents/Head';
9
- export default function MDXHead(props: Props): JSX.Element;
@@ -1,23 +0,0 @@
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
- // MDX elements are wrapped through the MDX pragma. In some cases (notably usage
10
- // with Head/Helmet) we need to unwrap those elements.
11
- function unwrapMDXElement(element) {
12
- if (element.props?.mdxType && element.props.originalType) {
13
- const {mdxType, originalType, ...newProps} = element.props;
14
- return React.createElement(element.props.originalType, newProps);
15
- }
16
- return element;
17
- }
18
- export default function MDXHead(props) {
19
- const unwrappedChildren = React.Children.map(props.children, (child) =>
20
- React.isValidElement(child) ? unwrapMDXElement(child) : child,
21
- );
22
- return <Head {...props}>{unwrappedChildren}</Head>;
23
- }
@@ -1,31 +0,0 @@
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} from 'react';
9
- import Head, {type Props as HeadProps} from '@docusaurus/Head';
10
- import type {Props} from '@theme/MDXComponents/Head';
11
-
12
- type MDXElement = ReactElement<
13
- {mdxType?: string; originalType?: string} | undefined
14
- >;
15
-
16
- // MDX elements are wrapped through the MDX pragma. In some cases (notably usage
17
- // with Head/Helmet) we need to unwrap those elements.
18
- function unwrapMDXElement(element: MDXElement) {
19
- if (element.props?.mdxType && element.props.originalType) {
20
- const {mdxType, originalType, ...newProps} = element.props;
21
- return React.createElement(element.props.originalType, newProps);
22
- }
23
- return element;
24
- }
25
-
26
- export default function MDXHead(props: Props): JSX.Element {
27
- const unwrappedChildren = React.Children.map(props.children, (child) =>
28
- React.isValidElement(child) ? unwrapMDXElement(child as MDXElement) : child,
29
- );
30
- return <Head {...(props as HeadProps)}>{unwrappedChildren}</Head>;
31
- }