@docusaurus/theme-classic 0.0.0-4707 → 0.0.0-4710

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4707",
3
+ "version": "0.0.0-4710",
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-4707",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4707",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4707",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4707",
28
- "@docusaurus/theme-common": "0.0.0-4707",
29
- "@docusaurus/theme-translations": "0.0.0-4707",
30
- "@docusaurus/utils": "0.0.0-4707",
31
- "@docusaurus/utils-common": "0.0.0-4707",
32
- "@docusaurus/utils-validation": "0.0.0-4707",
24
+ "@docusaurus/core": "0.0.0-4710",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4710",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4710",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4710",
28
+ "@docusaurus/theme-common": "0.0.0-4710",
29
+ "@docusaurus/theme-translations": "0.0.0-4710",
30
+ "@docusaurus/utils": "0.0.0-4710",
31
+ "@docusaurus/utils-common": "0.0.0-4710",
32
+ "@docusaurus/utils-validation": "0.0.0-4710",
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-4707",
46
- "@docusaurus/types": "0.0.0-4707",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4710",
46
+ "@docusaurus/types": "0.0.0-4710",
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": "0092bf6871799bbc934553842aafd69768517768"
62
+ "gitHead": "b87b7d90b4b0f155d034b52406c2056ea1dced54"
63
63
  }
@@ -37,11 +37,62 @@ export default function getSwizzleConfig(): SwizzleConfig {
37
37
  },
38
38
  Footer: {
39
39
  actions: {
40
- eject: 'unsafe', // TODO split footer into smaller parts
40
+ eject: 'safe',
41
41
  wrap: 'safe',
42
42
  },
43
43
  description: "The footer component of you site's layout",
44
44
  },
45
+ 'Footer/Copyright': {
46
+ actions: {
47
+ eject: 'safe',
48
+ wrap: 'safe',
49
+ },
50
+ description: 'The footer copyright',
51
+ },
52
+ 'Footer/Layout': {
53
+ actions: {
54
+ eject: 'safe',
55
+ wrap: 'safe',
56
+ },
57
+ description: 'The footer main layout component',
58
+ },
59
+ 'Footer/LinkItem': {
60
+ actions: {
61
+ eject: 'safe',
62
+ wrap: 'safe',
63
+ },
64
+ description: 'The footer link item component',
65
+ },
66
+ 'Footer/Links': {
67
+ actions: {
68
+ eject: 'safe',
69
+ wrap: 'safe',
70
+ },
71
+ description: 'The footer component rendering the footer links',
72
+ },
73
+ 'Footer/Links/MultiColumn': {
74
+ actions: {
75
+ eject: 'safe',
76
+ wrap: 'safe',
77
+ },
78
+ description:
79
+ 'The footer component rendering the footer links with a multi-column layout',
80
+ },
81
+ 'Footer/Links/Simple': {
82
+ actions: {
83
+ eject: 'safe',
84
+ wrap: 'safe',
85
+ },
86
+ description:
87
+ 'The footer component rendering the footer links with a simple layout (single row)',
88
+ },
89
+ 'Footer/Logo': {
90
+ actions: {
91
+ eject: 'safe',
92
+ wrap: 'safe',
93
+ },
94
+ description: 'The footer logo',
95
+ },
45
96
  IconArrow: {
46
97
  actions: {
47
98
  eject: 'safe',
@@ -0,0 +1,22 @@
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/Footer/Copyright';
10
+
11
+ export default function FooterCopyright({copyright}: Props): JSX.Element {
12
+ return (
13
+ <div
14
+ className="footer__copyright"
15
+ // Developer provided the HTML, so assume it's safe.
16
+ // eslint-disable-next-line react/no-danger
17
+ dangerouslySetInnerHTML={{
18
+ __html: copyright,
19
+ }}
20
+ />
21
+ );
22
+ }
@@ -0,0 +1,34 @@
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/Footer/Layout';
11
+
12
+ export default function FooterLayout({
13
+ style,
14
+ links,
15
+ logo,
16
+ copyright,
17
+ }: Props): JSX.Element {
18
+ return (
19
+ <footer
20
+ className={clsx('footer', {
21
+ 'footer--dark': style === 'dark',
22
+ })}>
23
+ <div className="container container-fluid">
24
+ {links}
25
+ {(logo || copyright) && (
26
+ <div className="footer__bottom text--center">
27
+ {logo && <div className="margin-bottom--sm">{logo}</div>}
28
+ {copyright}
29
+ </div>
30
+ )}
31
+ </div>
32
+ </footer>
33
+ );
34
+ }
@@ -0,0 +1,38 @@
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
+
10
+ import Link from '@docusaurus/Link';
11
+ import useBaseUrl from '@docusaurus/useBaseUrl';
12
+ import isInternalUrl from '@docusaurus/isInternalUrl';
13
+ import IconExternalLink from '@theme/IconExternalLink';
14
+ import type {Props} from '@theme/Footer/LinkItem';
15
+
16
+ export default function FooterLinkItem({item}: Props): JSX.Element {
17
+ const {to, href, label, prependBaseUrlToHref, ...props} = item;
18
+ const toUrl = useBaseUrl(to);
19
+ const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
20
+
21
+ return (
22
+ <Link
23
+ className="footer__link-item"
24
+ {...(href
25
+ ? {
26
+ href: prependBaseUrlToHref ? normalizedHref : href,
27
+ }
28
+ : {
29
+ to: toUrl,
30
+ })}
31
+ {...props}>
32
+ <span>
33
+ {label}
34
+ {href && !isInternalUrl(href) && <IconExternalLink />}
35
+ </span>
36
+ </Link>
37
+ );
38
+ }
@@ -0,0 +1,53 @@
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/Footer/Links/MultiColumn';
10
+ import LinkItem from '@theme/Footer/LinkItem';
11
+
12
+ type ColumnType = Props['columns'][number];
13
+ type ColumnItemType = ColumnType['items'][number];
14
+
15
+ function ColumnLinkItem({item}: {item: ColumnItemType}) {
16
+ return item.html ? (
17
+ <li
18
+ className="footer__item"
19
+ // Developer provided the HTML, so assume it's safe.
20
+ // eslint-disable-next-line react/no-danger
21
+ dangerouslySetInnerHTML={{
22
+ __html: item.html,
23
+ }}
24
+ />
25
+ ) : (
26
+ <li key={item.href || item.to} className="footer__item">
27
+ <LinkItem item={item} />
28
+ </li>
29
+ );
30
+ }
31
+
32
+ function Column({column}: {column: ColumnType}) {
33
+ return (
34
+ <div className="col footer__col">
35
+ <div className="footer__title">{column.title}</div>
36
+ <ul className="footer__items">
37
+ {column.items.map((item, i) => (
38
+ <ColumnLinkItem key={i} item={item} />
39
+ ))}
40
+ </ul>
41
+ </div>
42
+ );
43
+ }
44
+
45
+ export default function FooterLinksMultiColumn({columns}: Props): JSX.Element {
46
+ return (
47
+ <div className="row footer__links">
48
+ {columns.map((column, i) => (
49
+ <Column key={i} column={column} />
50
+ ))}
51
+ </div>
52
+ );
53
+ }
@@ -0,0 +1,44 @@
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/Footer/Links/Simple';
10
+ import LinkItem from '@theme/Footer/LinkItem';
11
+
12
+ function Separator() {
13
+ return <span className="footer__link-separator">·</span>;
14
+ }
15
+
16
+ function SimpleLinkItem({item}: {item: Props['links'][number]}) {
17
+ return item.html ? (
18
+ <span
19
+ className="footer__link-item"
20
+ // Developer provided the HTML, so assume it's safe.
21
+ // eslint-disable-next-line react/no-danger
22
+ dangerouslySetInnerHTML={{
23
+ __html: item.html,
24
+ }}
25
+ />
26
+ ) : (
27
+ <LinkItem item={item} />
28
+ );
29
+ }
30
+
31
+ export default function FooterLinksSimple({links}: Props): JSX.Element {
32
+ return (
33
+ <div className="footer__links text--center">
34
+ <div className="footer__links">
35
+ {links.map((item, i) => (
36
+ <React.Fragment key={i}>
37
+ <SimpleLinkItem item={item} />
38
+ {links.length !== i + 1 && <Separator />}
39
+ </React.Fragment>
40
+ ))}
41
+ </div>
42
+ </div>
43
+ );
44
+ }
@@ -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 from 'react';
9
+
10
+ import {isMultiColumnFooterLinks} from '@docusaurus/theme-common';
11
+ import type {Props} from '@theme/Footer/Links';
12
+ import FooterLinksMultiColumn from '@theme/Footer/Links/MultiColumn';
13
+ import FooterLinksSimple from '@theme/Footer/Links/Simple';
14
+
15
+ export default function FooterLinks({links}: Props): JSX.Element {
16
+ return isMultiColumnFooterLinks(links) ? (
17
+ <FooterLinksMultiColumn columns={links} />
18
+ ) : (
19
+ <FooterLinksSimple links={links} />
20
+ );
21
+ }
@@ -0,0 +1,41 @@
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
+
10
+ import Link from '@docusaurus/Link';
11
+ import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
12
+ import styles from './styles.module.css';
13
+ import ThemedImage from '@theme/ThemedImage';
14
+ import type {Props} from '@theme/Footer/Logo';
15
+
16
+ function LogoImage({logo}: Props) {
17
+ const {withBaseUrl} = useBaseUrlUtils();
18
+ const sources = {
19
+ light: withBaseUrl(logo.src),
20
+ dark: withBaseUrl(logo.srcDark ?? logo.src),
21
+ };
22
+ return (
23
+ <ThemedImage
24
+ className="footer__logo"
25
+ alt={logo.alt}
26
+ sources={sources}
27
+ width={logo.width}
28
+ height={logo.height}
29
+ />
30
+ );
31
+ }
32
+
33
+ export default function FooterLogo({logo}: Props): JSX.Element {
34
+ return logo.href ? (
35
+ <Link href={logo.href} className={styles.footerLogoLink}>
36
+ <LogoImage logo={logo} />
37
+ </Link>
38
+ ) : (
39
+ <LogoImage logo={logo} />
40
+ );
41
+ }
@@ -6,185 +6,27 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import clsx from 'clsx';
10
9
 
11
- import Link from '@docusaurus/Link';
12
- import {
13
- type FooterLinkItem,
14
- useThemeConfig,
15
- type MultiColumnFooter,
16
- type SimpleFooter,
17
- } from '@docusaurus/theme-common';
18
- import useBaseUrl, {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
19
- import isInternalUrl from '@docusaurus/isInternalUrl';
20
- import styles from './styles.module.css';
21
- import ThemedImage from '@theme/ThemedImage';
22
- import IconExternalLink from '@theme/IconExternalLink';
23
-
24
- function FooterLink({
25
- to,
26
- href,
27
- label,
28
- prependBaseUrlToHref,
29
- ...props
30
- }: FooterLinkItem) {
31
- const toUrl = useBaseUrl(to);
32
- const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
33
-
34
- return (
35
- <Link
36
- className="footer__link-item"
37
- {...(href
38
- ? {
39
- href: prependBaseUrlToHref ? normalizedHref : href,
40
- }
41
- : {
42
- to: toUrl,
43
- })}
44
- {...props}>
45
- <span>
46
- {label}
47
- {href && !isInternalUrl(href) && <IconExternalLink />}
48
- </span>
49
- </Link>
50
- );
51
- }
52
-
53
- function FooterLogo({logo}: {logo: SimpleFooter['logo']}) {
54
- const {withBaseUrl} = useBaseUrlUtils();
55
- if (!logo?.src) {
56
- return null;
57
- }
58
- const sources = {
59
- light: withBaseUrl(logo.src),
60
- dark: withBaseUrl(logo.srcDark ?? logo.src),
61
- };
62
- const image = (
63
- <ThemedImage
64
- className="footer__logo"
65
- alt={logo.alt}
66
- sources={sources}
67
- width={logo.width}
68
- height={logo.height}
69
- />
70
- );
71
- return (
72
- <div className="margin-bottom--sm">
73
- {logo.href ? (
74
- <Link href={logo.href} className={styles.footerLogoLink}>
75
- {image}
76
- </Link>
77
- ) : (
78
- image
79
- )}
80
- </div>
81
- );
82
- }
83
-
84
- function MultiColumnLinks({links}: {links: MultiColumnFooter['links']}) {
85
- return (
86
- <>
87
- {links.map((linkItem, i) => (
88
- <div key={i} className="col footer__col">
89
- <div className="footer__title">{linkItem.title}</div>
90
- <ul className="footer__items">
91
- {linkItem.items.map((item, key) =>
92
- item.html ? (
93
- <li
94
- key={key}
95
- className="footer__item"
96
- // Developer provided the HTML, so assume it's safe.
97
- // eslint-disable-next-line react/no-danger
98
- dangerouslySetInnerHTML={{
99
- __html: item.html,
100
- }}
101
- />
102
- ) : (
103
- <li key={item.href || item.to} className="footer__item">
104
- <FooterLink {...item} />
105
- </li>
106
- ),
107
- )}
108
- </ul>
109
- </div>
110
- ))}
111
- </>
112
- );
113
- }
114
-
115
- function SimpleLinks({links}: {links: SimpleFooter['links']}) {
116
- return (
117
- <div className="footer__links">
118
- {links.map((item, key) => (
119
- <React.Fragment key={key}>
120
- {item.html ? (
121
- <span
122
- className="footer__link-item"
123
- // Developer provided the HTML, so assume it's safe.
124
- // eslint-disable-next-line react/no-danger
125
- dangerouslySetInnerHTML={{
126
- __html: item.html,
127
- }}
128
- />
129
- ) : (
130
- <FooterLink {...item} />
131
- )}
132
- {links.length !== key + 1 && (
133
- <span className="footer__link-separator">·</span>
134
- )}
135
- </React.Fragment>
136
- ))}
137
- </div>
138
- );
139
- }
140
-
141
- function isMultiColumnFooterLinks(
142
- links: MultiColumnFooter['links'] | SimpleFooter['links'],
143
- ): links is MultiColumnFooter['links'] {
144
- return 'title' in links[0]!;
145
- }
10
+ import {useThemeConfig} from '@docusaurus/theme-common';
11
+ import FooterLinks from '@theme/Footer/Links';
12
+ import FooterLogo from '@theme/Footer/Logo';
13
+ import FooterCopyright from '@theme/Footer/Copyright';
14
+ import FooterLayout from '@theme/Footer/Layout';
146
15
 
147
16
  function Footer(): JSX.Element | null {
148
17
  const {footer} = useThemeConfig();
149
18
  if (!footer) {
150
19
  return null;
151
20
  }
152
- const {copyright, links, logo} = footer;
21
+ const {copyright, links, logo, style} = footer;
153
22
 
154
23
  return (
155
- <footer
156
- className={clsx('footer', {
157
- 'footer--dark': footer.style === 'dark',
158
- })}>
159
- <div className="container container-fluid">
160
- {links &&
161
- links.length > 0 &&
162
- (isMultiColumnFooterLinks(links) ? (
163
- <div className="row footer__links">
164
- <MultiColumnLinks links={links} />
165
- </div>
166
- ) : (
167
- <div className="footer__links text--center">
168
- <SimpleLinks links={links} />
169
- </div>
170
- ))}
171
- {(logo || copyright) && (
172
- <div className="footer__bottom text--center">
173
- <FooterLogo logo={logo} />
174
- {copyright && (
175
- <div
176
- className="footer__copyright"
177
- // Developer provided the HTML, so assume it's safe.
178
- // eslint-disable-next-line react/no-danger
179
- dangerouslySetInnerHTML={{
180
- __html: copyright,
181
- }}
182
- />
183
- )}
184
- </div>
185
- )}
186
- </div>
187
- </footer>
24
+ <FooterLayout
25
+ style={style}
26
+ links={links && links.length > 0 && <FooterLinks links={links} />}
27
+ logo={logo && <FooterLogo logo={logo} />}
28
+ copyright={copyright && <FooterCopyright copyright={copyright} />}
29
+ />
188
30
  );
189
31
  }
190
32
 
@@ -6,8 +6,8 @@
6
6
  */
7
7
 
8
8
  import React, {
9
- type ComponentProps,
10
9
  isValidElement,
10
+ type ComponentProps,
11
11
  type ReactElement,
12
12
  } from 'react';
13
13
  import Head from '@docusaurus/Head';
@@ -52,7 +52,7 @@ const MDXComponents: MDXComponentsObject = {
52
52
  const shouldBeInline = React.Children.toArray(props.children).every(
53
53
  (el) =>
54
54
  (typeof el === 'string' && !el.includes('\n')) ||
55
- (React.isValidElement(el) && inlineElements.includes(el.props.mdxType)),
55
+ (isValidElement(el) && inlineElements.includes(el.props.mdxType)),
56
56
  );
57
57
 
58
58
  return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
@@ -8,7 +8,6 @@
8
8
  import React, {
9
9
  useState,
10
10
  cloneElement,
11
- Children,
12
11
  isValidElement,
13
12
  type ReactElement,
14
13
  } from 'react';
@@ -40,7 +39,7 @@ function TabsComponent(props: Props): JSX.Element {
40
39
  groupId,
41
40
  className,
42
41
  } = props;
43
- const children = Children.map(props.children, (child) => {
42
+ const children = React.Children.map(props.children, (child) => {
44
43
  if (isValidElement(child) && isTabItem(child)) {
45
44
  return child;
46
45
  }