@docusaurus/theme-classic 0.0.0-4698 → 0.0.0-4701

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.
@@ -89,6 +89,13 @@ function getSwizzleConfig() {
89
89
  },
90
90
  description: 'The MDX components to use for rendering MDX files. Meant to be ejected.'
91
91
  },
92
+ MDXContent: {
93
+ actions: {
94
+ eject: 'safe',
95
+ wrap: 'safe'
96
+ },
97
+ description: 'A component wrapping all MDX content and providing the MDXComponents to the MDX context'
98
+ },
92
99
  // TODO should probably not even appear here
93
100
  'NavbarItem/utils': {
94
101
  actions: {
@@ -343,6 +343,16 @@ declare module '@theme/MDXComponents' {
343
343
  export default MDXComponents;
344
344
  }
345
345
 
346
+ declare module '@theme/MDXContent' {
347
+ import type {ReactNode} from 'react';
348
+
349
+ export interface Props {
350
+ readonly children: ReactNode;
351
+ }
352
+
353
+ export default function MDXContent(props: Props): JSX.Element;
354
+ }
355
+
346
356
  declare module '@theme/Navbar' {
347
357
  export default function Navbar(): JSX.Element;
348
358
  }
@@ -6,13 +6,12 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import {MDXProvider} from '@mdx-js/react';
10
9
  import Translate, {translate} from '@docusaurus/Translate';
11
10
  import Link from '@docusaurus/Link';
12
11
  import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
13
12
  import {usePluralForm} from '@docusaurus/theme-common';
14
13
  import {blogPostContainerID} from '@docusaurus/utils-common';
15
- import MDXComponents from '@theme/MDXComponents';
14
+ import MDXContent from '@theme/MDXContent';
16
15
  import EditThisPage from '@theme/EditThisPage';
17
16
  import styles from './styles.module.css';
18
17
  import TagsListInline from '@theme/TagsListInline';
@@ -108,7 +107,7 @@ export default function BlogPostItem(props) {
108
107
  id={isBlogPostPage ? blogPostContainerID : undefined}
109
108
  className="markdown"
110
109
  itemProp="articleBody">
111
- <MDXProvider components={MDXComponents}>{children}</MDXProvider>
110
+ <MDXContent>{children}</MDXContent>
112
111
  </div>
113
112
 
114
113
  {(tagsExists || truncated) && (
@@ -17,6 +17,7 @@ import Heading from '@theme/Heading';
17
17
  import styles from './styles.module.css';
18
18
  import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
19
19
  import DocBreadcrumbs from '@theme/DocBreadcrumbs';
20
+ import MDXContent from '@theme/MDXContent';
20
21
  export default function DocItem(props) {
21
22
  const {content: DocContent} = props;
22
23
  const {metadata, frontMatter, assets} = DocContent;
@@ -86,8 +87,9 @@ export default function DocItem(props) {
86
87
  <Heading as="h1">{title}</Heading>
87
88
  </header>
88
89
  )}
89
-
90
- <DocContent />
90
+ <MDXContent>
91
+ <DocContent />
92
+ </MDXContent>
91
93
  </div>
92
94
 
93
95
  <DocItemFooter {...props} />
@@ -5,11 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, {useState, useCallback} from 'react';
8
- import {MDXProvider} from '@mdx-js/react';
9
8
  import renderRoutes from '@docusaurus/renderRoutes';
10
9
  import Layout from '@theme/Layout';
11
10
  import DocSidebar from '@theme/DocSidebar';
12
- import MDXComponents from '@theme/MDXComponents';
13
11
  import NotFound from '@theme/NotFound';
14
12
  import IconArrow from '@theme/IconArrow';
15
13
  import BackToTopButton from '@theme/BackToTopButton';
@@ -123,7 +121,7 @@ function DocPageContent({
123
121
  [styles.docItemWrapperEnhanced]: hiddenSidebarContainer,
124
122
  },
125
123
  )}>
126
- <MDXProvider components={MDXComponents}>{children}</MDXProvider>
124
+ {children}
127
125
  </div>
128
126
  </main>
129
127
  </div>
@@ -250,14 +250,10 @@ function DocSidebarItemLink({
250
250
  onClick: onItemClick ? () => onItemClick(item) : undefined,
251
251
  })}
252
252
  {...props}>
253
- {isInternalUrl(href) ? (
254
- label
255
- ) : (
256
- <span>
257
- {label}
258
- <IconExternalLink />
259
- </span>
260
- )}
253
+ <span>
254
+ {label}
255
+ {!isInternalUrl(href) && <IconExternalLink />}
256
+ </span>
261
257
  </Link>
262
258
  </li>
263
259
  );
@@ -30,14 +30,10 @@ function FooterLink({to, href, label, prependBaseUrlToHref, ...props}) {
30
30
  to: toUrl,
31
31
  })}
32
32
  {...props}>
33
- {href && !isInternalUrl(href) ? (
34
- <span>
35
- {label}
36
- <IconExternalLink />
37
- </span>
38
- ) : (
39
- label
40
- )}
33
+ <span>
34
+ {label}
35
+ {href && !isInternalUrl(href) && <IconExternalLink />}
36
+ </span>
41
37
  </Link>
42
38
  );
43
39
  }
@@ -0,0 +1,12 @@
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 {MDXProvider} from '@mdx-js/react';
9
+ import MDXComponents from '@theme/MDXComponents';
10
+ export default function MDXContent({children}) {
11
+ return <MDXProvider components={MDXComponents}>{children}</MDXProvider>;
12
+ }
@@ -7,8 +7,7 @@
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import Layout from '@theme/Layout';
10
- import {MDXProvider} from '@mdx-js/react';
11
- import MDXComponents from '@theme/MDXComponents';
10
+ import MDXContent from '@theme/MDXContent';
12
11
  import TOC from '@theme/TOC';
13
12
  import {ThemeClassNames} from '@docusaurus/theme-common';
14
13
  import styles from './styles.module.css';
@@ -29,9 +28,9 @@ export default function MDXPage(props) {
29
28
  <main className="container container--fluid margin-vert--lg">
30
29
  <div className={clsx('row', styles.mdxPageWrapper)}>
31
30
  <div className={clsx('col', !hideTableOfContents && 'col--8')}>
32
- <MDXProvider components={MDXComponents}>
31
+ <MDXContent>
33
32
  <MDXPageContent />
34
- </MDXProvider>
33
+ </MDXContent>
35
34
  </div>
36
35
  {!hideTableOfContents && MDXPageContent.toc && (
37
36
  <div className="col col--2">
@@ -52,19 +52,17 @@ export default function NavbarNavLink({
52
52
  : null),
53
53
  })}
54
54
  {...props}>
55
- {isExternalLink ? (
56
- <span>
57
- {label}
55
+ <span>
56
+ {label}
57
+ {isExternalLink && (
58
58
  <IconExternalLink
59
59
  {...(isDropdownLink && {
60
60
  width: 12,
61
61
  height: 12,
62
62
  })}
63
63
  />
64
- </span>
65
- ) : (
66
- label
67
- )}
64
+ )}
65
+ </span>
68
66
  </Link>
69
67
  );
70
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4698",
3
+ "version": "0.0.0-4701",
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-4698",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4698",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4698",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4698",
28
- "@docusaurus/theme-common": "0.0.0-4698",
29
- "@docusaurus/theme-translations": "0.0.0-4698",
30
- "@docusaurus/utils": "0.0.0-4698",
31
- "@docusaurus/utils-common": "0.0.0-4698",
32
- "@docusaurus/utils-validation": "0.0.0-4698",
24
+ "@docusaurus/core": "0.0.0-4701",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4701",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4701",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4701",
28
+ "@docusaurus/theme-common": "0.0.0-4701",
29
+ "@docusaurus/theme-translations": "0.0.0-4701",
30
+ "@docusaurus/utils": "0.0.0-4701",
31
+ "@docusaurus/utils-common": "0.0.0-4701",
32
+ "@docusaurus/utils-validation": "0.0.0-4701",
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.3.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4698",
46
- "@docusaurus/types": "0.0.0-4698",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4701",
46
+ "@docusaurus/types": "0.0.0-4701",
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": "767623e1e1a5f3dfea660eb8a6733b65de59f1c0"
62
+ "gitHead": "d61c50e6864073ecd948822e64d2f99a825f59fc"
63
63
  }
@@ -85,6 +85,14 @@ export default function getSwizzleConfig(): SwizzleConfig {
85
85
  description:
86
86
  'The MDX components to use for rendering MDX files. Meant to be ejected.',
87
87
  },
88
+ MDXContent: {
89
+ actions: {
90
+ eject: 'safe',
91
+ wrap: 'safe',
92
+ },
93
+ description:
94
+ 'A component wrapping all MDX content and providing the MDXComponents to the MDX context',
95
+ },
88
96
  // TODO should probably not even appear here
89
97
  'NavbarItem/utils': {
90
98
  actions: {
@@ -7,13 +7,12 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import {MDXProvider} from '@mdx-js/react';
11
10
  import Translate, {translate} from '@docusaurus/Translate';
12
11
  import Link from '@docusaurus/Link';
13
12
  import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
14
13
  import {usePluralForm} from '@docusaurus/theme-common';
15
14
  import {blogPostContainerID} from '@docusaurus/utils-common';
16
- import MDXComponents from '@theme/MDXComponents';
15
+ import MDXContent from '@theme/MDXContent';
17
16
  import EditThisPage from '@theme/EditThisPage';
18
17
  import type {Props} from '@theme/BlogPostItem';
19
18
 
@@ -108,7 +107,7 @@ export default function BlogPostItem(props: Props): JSX.Element {
108
107
  id={isBlogPostPage ? blogPostContainerID : undefined}
109
108
  className="markdown"
110
109
  itemProp="articleBody">
111
- <MDXProvider components={MDXComponents}>{children}</MDXProvider>
110
+ <MDXContent>{children}</MDXContent>
112
111
  </div>
113
112
 
114
113
  {(tagsExists || truncated) && (
@@ -19,6 +19,7 @@ import Heading from '@theme/Heading';
19
19
  import styles from './styles.module.css';
20
20
  import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
21
21
  import DocBreadcrumbs from '@theme/DocBreadcrumbs';
22
+ import MDXContent from '@theme/MDXContent';
22
23
 
23
24
  export default function DocItem(props: Props): JSX.Element {
24
25
  const {content: DocContent} = props;
@@ -87,8 +88,9 @@ export default function DocItem(props: Props): JSX.Element {
87
88
  <Heading as="h1">{title}</Heading>
88
89
  </header>
89
90
  )}
90
-
91
- <DocContent />
91
+ <MDXContent>
92
+ <DocContent />
93
+ </MDXContent>
92
94
  </div>
93
95
 
94
96
  <DocItemFooter {...props} />
@@ -6,13 +6,10 @@
6
6
  */
7
7
 
8
8
  import React, {type ReactNode, useState, useCallback} from 'react';
9
- import {MDXProvider} from '@mdx-js/react';
10
-
11
9
  import renderRoutes from '@docusaurus/renderRoutes';
12
10
  import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
13
11
  import Layout from '@theme/Layout';
14
12
  import DocSidebar from '@theme/DocSidebar';
15
- import MDXComponents from '@theme/MDXComponents';
16
13
  import NotFound from '@theme/NotFound';
17
14
  import type {DocumentRoute} from '@theme/DocItem';
18
15
  import type {Props} from '@theme/DocPage';
@@ -137,7 +134,7 @@ function DocPageContent({
137
134
  [styles.docItemWrapperEnhanced!]: hiddenSidebarContainer,
138
135
  },
139
136
  )}>
140
- <MDXProvider components={MDXComponents}>{children}</MDXProvider>
137
+ {children}
141
138
  </div>
142
139
  </main>
143
140
  </div>
@@ -269,14 +269,10 @@ function DocSidebarItemLink({
269
269
  onClick: onItemClick ? () => onItemClick(item) : undefined,
270
270
  })}
271
271
  {...props}>
272
- {isInternalUrl(href) ? (
273
- label
274
- ) : (
275
- <span>
276
- {label}
277
- <IconExternalLink />
278
- </span>
279
- )}
272
+ <span>
273
+ {label}
274
+ {!isInternalUrl(href) && <IconExternalLink />}
275
+ </span>
280
276
  </Link>
281
277
  </li>
282
278
  );
@@ -42,14 +42,10 @@ function FooterLink({
42
42
  to: toUrl,
43
43
  })}
44
44
  {...props}>
45
- {href && !isInternalUrl(href) ? (
46
- <span>
47
- {label}
48
- <IconExternalLink />
49
- </span>
50
- ) : (
51
- label
52
- )}
45
+ <span>
46
+ {label}
47
+ {href && !isInternalUrl(href) && <IconExternalLink />}
48
+ </span>
53
49
  </Link>
54
50
  );
55
51
  }
@@ -0,0 +1,15 @@
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 {MDXProvider} from '@mdx-js/react';
10
+ import MDXComponents from '@theme/MDXComponents';
11
+ import type {Props} from '@theme/MDXContent';
12
+
13
+ export default function MDXContent({children}: Props): JSX.Element {
14
+ return <MDXProvider components={MDXComponents}>{children}</MDXProvider>;
15
+ }
@@ -8,8 +8,7 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import Layout from '@theme/Layout';
11
- import {MDXProvider} from '@mdx-js/react';
12
- import MDXComponents from '@theme/MDXComponents';
11
+ import MDXContent from '@theme/MDXContent';
13
12
  import type {Props} from '@theme/MDXPage';
14
13
  import TOC from '@theme/TOC';
15
14
  import {ThemeClassNames} from '@docusaurus/theme-common';
@@ -34,9 +33,9 @@ export default function MDXPage(props: Props): JSX.Element {
34
33
  <main className="container container--fluid margin-vert--lg">
35
34
  <div className={clsx('row', styles.mdxPageWrapper)}>
36
35
  <div className={clsx('col', !hideTableOfContents && 'col--8')}>
37
- <MDXProvider components={MDXComponents}>
36
+ <MDXContent>
38
37
  <MDXPageContent />
39
- </MDXProvider>
38
+ </MDXContent>
40
39
  </div>
41
40
  {!hideTableOfContents && MDXPageContent.toc && (
42
41
  <div className="col col--2">
@@ -55,14 +55,12 @@ export default function NavbarNavLink({
55
55
  : null),
56
56
  })}
57
57
  {...props}>
58
- {isExternalLink ? (
59
- <span>
60
- {label}
58
+ <span>
59
+ {label}
60
+ {isExternalLink && (
61
61
  <IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
62
- </span>
63
- ) : (
64
- label
65
- )}
62
+ )}
63
+ </span>
66
64
  </Link>
67
65
  );
68
66
  }
@@ -343,6 +343,16 @@ declare module '@theme/MDXComponents' {
343
343
  export default MDXComponents;
344
344
  }
345
345
 
346
+ declare module '@theme/MDXContent' {
347
+ import type {ReactNode} from 'react';
348
+
349
+ export interface Props {
350
+ readonly children: ReactNode;
351
+ }
352
+
353
+ export default function MDXContent(props: Props): JSX.Element;
354
+ }
355
+
346
356
  declare module '@theme/Navbar' {
347
357
  export default function Navbar(): JSX.Element;
348
358
  }