@docusaurus/theme-classic 3.8.1 → 3.9.0-canary-6403

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.
Files changed (54) hide show
  1. package/lib/index.js +0 -1
  2. package/lib/inlineScripts.d.ts +1 -1
  3. package/lib/inlineScripts.js +21 -20
  4. package/lib/theme/Blog/Components/Author/Socials/index.js +3 -1
  5. package/lib/theme/Blog/Components/Author/index.js +6 -2
  6. package/lib/theme/CodeBlock/Buttons/CopyButton/index.js +6 -6
  7. package/lib/theme/DocSidebarItem/Category/index.d.ts +1 -1
  8. package/lib/theme/DocSidebarItem/Category/index.js +96 -33
  9. package/lib/theme/DocSidebarItem/Category/styles.module.css +26 -0
  10. package/lib/theme/DocSidebarItem/Link/index.js +8 -1
  11. package/lib/theme/DocSidebarItem/Link/styles.module.css +8 -0
  12. package/lib/theme/Heading/index.js +2 -1
  13. package/lib/theme/Icon/ExternalLink/index.js +6 -1
  14. package/lib/theme/Icon/Socials/Bluesky/index.js +6 -5
  15. package/lib/theme/{MDXComponents/A.js → Icon/Socials/Bluesky/styles.module.css} +7 -4
  16. package/lib/theme/Icon/Socials/Default/index.js +6 -6
  17. package/lib/theme/Icon/Socials/Email/index.d.ts +9 -0
  18. package/lib/theme/Icon/Socials/Email/index.js +25 -0
  19. package/lib/theme/Icon/Socials/LinkedIn/index.d.ts +1 -1
  20. package/lib/theme/Icon/Socials/LinkedIn/index.js +6 -5
  21. package/lib/theme/Icon/Socials/LinkedIn/styles.module.css +14 -0
  22. package/lib/theme/MDXComponents/A/index.js +36 -0
  23. package/lib/theme/MDXComponents/A/styles.module.css +20 -0
  24. package/lib/theme/Navbar/Search/styles.module.css +1 -2
  25. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +3 -2
  26. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +61 -15
  27. package/lib/theme/Tabs/index.js +9 -1
  28. package/package.json +16 -17
  29. package/src/index.ts +0 -1
  30. package/src/inlineScripts.ts +27 -20
  31. package/src/theme/Blog/Components/Author/Socials/index.tsx +3 -1
  32. package/src/theme/Blog/Components/Author/index.tsx +6 -2
  33. package/src/theme/CodeBlock/Buttons/CopyButton/index.tsx +6 -6
  34. package/src/theme/DocSidebarItem/Category/index.tsx +104 -32
  35. package/src/theme/DocSidebarItem/Category/styles.module.css +26 -0
  36. package/src/theme/DocSidebarItem/Link/index.tsx +9 -1
  37. package/src/theme/DocSidebarItem/Link/styles.module.css +8 -0
  38. package/src/theme/Heading/index.tsx +2 -1
  39. package/src/theme/Icon/ExternalLink/index.tsx +6 -1
  40. package/src/theme/Icon/Socials/Bluesky/index.tsx +7 -6
  41. package/src/theme/Icon/Socials/Bluesky/styles.module.css +14 -0
  42. package/src/theme/Icon/Socials/Default/index.tsx +6 -6
  43. package/src/theme/Icon/Socials/Email/index.tsx +28 -0
  44. package/src/theme/Icon/Socials/LinkedIn/index.tsx +7 -6
  45. package/src/theme/Icon/Socials/LinkedIn/styles.module.css +14 -0
  46. package/src/theme/MDXComponents/A/index.tsx +42 -0
  47. package/src/theme/MDXComponents/A/styles.module.css +20 -0
  48. package/src/theme/Navbar/Search/styles.module.css +1 -2
  49. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +3 -2
  50. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +66 -16
  51. package/src/theme/Tabs/index.tsx +9 -1
  52. package/src/theme-classic.d.ts +11 -1
  53. package/src/theme/MDXComponents/A.tsx +0 -14
  54. /package/lib/theme/MDXComponents/{A.d.ts → A/index.d.ts} +0 -0
@@ -0,0 +1,14 @@
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
+ [data-theme='dark'] .blueskySvg {
9
+ fill: var(--light);
10
+ }
11
+
12
+ [data-theme='light'] .blueskySvg {
13
+ fill: var(--dark);
14
+ }
@@ -7,7 +7,7 @@
7
7
 
8
8
  import type {ReactNode, SVGProps} from 'react';
9
9
 
10
- // SVG Source: https://tabler.io/
10
+ // SVG Source: https://github.com/tabler/tabler-icons
11
11
  function DefaultSocial(props: SVGProps<SVGSVGElement>): ReactNode {
12
12
  return (
13
13
  <svg
@@ -22,11 +22,11 @@ function DefaultSocial(props: SVGProps<SVGSVGElement>): ReactNode {
22
22
  strokeLinejoin="round"
23
23
  {...props}>
24
24
  <path stroke="none" d="M0 0h24v24H0z" fill="none" />
25
- <path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" />
26
- <path d="M3.6 9h16.8" />
27
- <path d="M3.6 15h16.8" />
28
- <path d="M11.5 3a17 17 0 0 0 0 18" />
29
- <path d="M12.5 3a17 17 0 0 1 0 18" />
25
+ <path d="M1.2 12a10.8 10.8 0 1 0 21.6 0a10.8 10.8 0 0 0 -21.6 0" />
26
+ <path d="M1.92 8.4h20.16" />
27
+ <path d="M1.92 15.6h20.16" />
28
+ <path d="M11.4 1.2a20.4 20.4 0 0 0 0 21.6" />
29
+ <path d="M12.6 1.2a20.4 20.4 0 0 1 0 21.6" />
30
30
  </svg>
31
31
  );
32
32
  }
@@ -0,0 +1,28 @@
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 type {ReactNode, SVGProps} from 'react';
9
+
10
+ // SVG Source: https://github.com/tabler/tabler-icons
11
+ function Email(props: SVGProps<SVGSVGElement>): ReactNode {
12
+ return (
13
+ <svg
14
+ xmlns="http://www.w3.org/2000/svg"
15
+ viewBox="0 0 24 24"
16
+ fill="none"
17
+ stroke="currentColor"
18
+ strokeLinecap="round"
19
+ strokeLinejoin="round"
20
+ strokeWidth={2}
21
+ {...props}>
22
+ <path stroke="none" d="M0 0h24v24H0z" />
23
+ <path d="M7.2 12a4.8 4.8 0 1 0 9.6 0 4.8 4.8 0 1 0-9.6 0" />
24
+ <path d="M16.8 12v1.8a3 3 0 0 0 6 0V12a10.8 10.8 0 1 0-6.6 9.936" />
25
+ </svg>
26
+ );
27
+ }
28
+ export default Email;
@@ -5,7 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {ReactNode, SVGProps} from 'react';
8
+ import type {SVGProps, ReactNode, CSSProperties} from 'react';
9
+ import clsx from 'clsx';
10
+ import styles from './styles.module.css';
9
11
 
10
12
  // SVG Source: https://svgl.app/
11
13
  function LinkedIn(props: SVGProps<SVGSVGElement>): ReactNode {
@@ -16,11 +18,10 @@ function LinkedIn(props: SVGProps<SVGSVGElement>): ReactNode {
16
18
  height="1em"
17
19
  preserveAspectRatio="xMidYMid"
18
20
  viewBox="0 0 256 256"
19
- {...props}>
20
- <path
21
- d="M218.123 218.127h-37.931v-59.403c0-14.165-.253-32.4-19.728-32.4-19.756 0-22.779 15.434-22.779 31.369v60.43h-37.93V95.967h36.413v16.694h.51a39.907 39.907 0 0 1 35.928-19.733c38.445 0 45.533 25.288 45.533 58.186l-.016 67.013ZM56.955 79.27c-12.157.002-22.014-9.852-22.016-22.009-.002-12.157 9.851-22.014 22.008-22.016 12.157-.003 22.014 9.851 22.016 22.008A22.013 22.013 0 0 1 56.955 79.27m18.966 138.858H37.95V95.967h37.97v122.16ZM237.033.018H18.89C8.58-.098.125 8.161-.001 18.471v219.053c.122 10.315 8.576 18.582 18.89 18.474h218.144c10.336.128 18.823-8.139 18.966-18.474V18.454c-.147-10.33-8.635-18.588-18.966-18.453"
22
- fill="#0A66C2"
23
- />
21
+ style={{'--dark': '#0a66c2', '--light': '#ffffffe6'} as CSSProperties}
22
+ {...props}
23
+ className={clsx(props.className, styles.linkedinSvg)}>
24
+ <path d="M218.123 218.127h-37.931v-59.403c0-14.165-.253-32.4-19.728-32.4-19.756 0-22.779 15.434-22.779 31.369v60.43h-37.93V95.967h36.413v16.694h.51a39.907 39.907 0 0 1 35.928-19.733c38.445 0 45.533 25.288 45.533 58.186l-.016 67.013ZM56.955 79.27c-12.157.002-22.014-9.852-22.016-22.009-.002-12.157 9.851-22.014 22.008-22.016 12.157-.003 22.014 9.851 22.016 22.008A22.013 22.013 0 0 1 56.955 79.27m18.966 138.858H37.95V95.967h37.97v122.16ZM237.033.018H18.89C8.58-.098.125 8.161-.001 18.471v219.053c.122 10.315 8.576 18.582 18.89 18.474h218.144c10.336.128 18.823-8.139 18.966-18.474V18.454c-.147-10.33-8.635-18.588-18.966-18.453" />
24
25
  </svg>
25
26
  );
26
27
  }
@@ -0,0 +1,14 @@
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
+ [data-theme='dark'] .linkedinSvg {
9
+ fill: var(--light);
10
+ }
11
+
12
+ [data-theme='light'] .linkedinSvg {
13
+ fill: var(--dark);
14
+ }
@@ -0,0 +1,42 @@
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 ReactNode} from 'react';
9
+ import clsx from 'clsx';
10
+ import Link from '@docusaurus/Link';
11
+ import {useThemeConfig} from '@docusaurus/theme-common';
12
+ import type {Props} from '@theme/MDXComponents/A';
13
+ import styles from './styles.module.css';
14
+
15
+ function isFootnoteRef(props: Props) {
16
+ return props['data-footnote-ref'] === true;
17
+ }
18
+
19
+ function FootnoteRefLink(props: Props) {
20
+ const {
21
+ navbar: {hideOnScroll},
22
+ } = useThemeConfig();
23
+ return (
24
+ <Link
25
+ {...props}
26
+ className={clsx(
27
+ hideOnScroll
28
+ ? styles.footnoteRefHideOnScrollNavbar
29
+ : styles.footnoteRefStickyNavbar,
30
+
31
+ props.className,
32
+ )}
33
+ />
34
+ );
35
+ }
36
+
37
+ export default function MDXA(props: Props): ReactNode {
38
+ if (isFootnoteRef(props)) {
39
+ return <FootnoteRefLink {...props} />;
40
+ }
41
+ return <Link {...props} />;
42
+ }
@@ -0,0 +1,20 @@
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
+ /*
9
+ When the navbar is sticky, ensure that on footnote click,
10
+ the browser does not scroll to the ref behind the navbar
11
+ See https://github.com/facebook/docusaurus/issues/11232
12
+ See also headings case https://x.com/JoshWComeau/status/1332015868725891076
13
+ */
14
+ .footnoteRefStickyNavbar {
15
+ scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem);
16
+ }
17
+
18
+ .footnoteRefHideOnScrollNavbar {
19
+ scroll-margin-top: 0.5rem;
20
+ }
@@ -22,7 +22,6 @@ See https://github.com/facebook/docusaurus/pull/9385
22
22
 
23
23
  @media (min-width: 997px) {
24
24
  .navbarSearchContainer {
25
- padding: var(--ifm-navbar-item-padding-vertical)
26
- var(--ifm-navbar-item-padding-horizontal);
25
+ padding: 0 var(--ifm-navbar-item-padding-horizontal);
27
26
  }
28
27
  }
@@ -13,7 +13,7 @@ import {
13
13
  useDocsPreferredVersion,
14
14
  } from '@docusaurus/plugin-content-docs/client';
15
15
  import {translate} from '@docusaurus/Translate';
16
- import {useLocation} from '@docusaurus/router';
16
+ import {useHistorySelector} from '@docusaurus/theme-common';
17
17
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
18
18
  import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
19
19
  import type {
@@ -119,7 +119,8 @@ export default function DocsVersionDropdownNavbarItem({
119
119
  versions: configs,
120
120
  ...props
121
121
  }: Props): ReactNode {
122
- const {search, hash} = useLocation();
122
+ const search = useHistorySelector((history) => history.location.search);
123
+ const hash = useHistorySelector((history) => history.location.hash);
123
124
  const activeDocContext = useActiveDocContext(docsPluginId);
124
125
  const {savePreferredVersionName} = useDocsPreferredVersion(docsPluginId);
125
126
  const versionItems = useVersionItems({docsPluginId, configs});
@@ -9,7 +9,7 @@ import React, {type ReactNode} from 'react';
9
9
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
10
  import {useAlternatePageUtils} from '@docusaurus/theme-common/internal';
11
11
  import {translate} from '@docusaurus/Translate';
12
- import {useLocation} from '@docusaurus/router';
12
+ import {mergeSearchStrings, useHistorySelector} from '@docusaurus/theme-common';
13
13
  import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
14
14
  import IconLanguage from '@theme/Icon/Language';
15
15
  import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
@@ -17,30 +17,80 @@ import type {Props} from '@theme/NavbarItem/LocaleDropdownNavbarItem';
17
17
 
18
18
  import styles from './styles.module.css';
19
19
 
20
+ function useLocaleDropdownUtils() {
21
+ const {
22
+ siteConfig,
23
+ i18n: {localeConfigs},
24
+ } = useDocusaurusContext();
25
+ const alternatePageUtils = useAlternatePageUtils();
26
+ const search = useHistorySelector((history) => history.location.search);
27
+ const hash = useHistorySelector((history) => history.location.hash);
28
+
29
+ const getLocaleConfig = (locale: string) => {
30
+ const localeConfig = localeConfigs[locale];
31
+ if (!localeConfig) {
32
+ throw new Error(
33
+ `Docusaurus bug, no locale config found for locale=${locale}`,
34
+ );
35
+ }
36
+ return localeConfig;
37
+ };
38
+
39
+ const getBaseURLForLocale = (locale: string) => {
40
+ const localeConfig = getLocaleConfig(locale);
41
+ const isSameDomain = localeConfig.url === siteConfig.url;
42
+ if (isSameDomain) {
43
+ // Shorter paths if localized sites are hosted on the same domain
44
+ // This reduces HTML size a bit
45
+ return `pathname://${alternatePageUtils.createUrl({
46
+ locale,
47
+ fullyQualified: false,
48
+ })}`;
49
+ }
50
+ return alternatePageUtils.createUrl({
51
+ locale,
52
+ fullyQualified: true,
53
+ });
54
+ };
55
+
56
+ return {
57
+ getURL: (locale: string, options: {queryString: string | undefined}) => {
58
+ // We have 2 query strings because
59
+ // - there's the current one
60
+ // - there's one user can provide through navbar config
61
+ // see https://github.com/facebook/docusaurus/pull/8915
62
+ const finalSearch = mergeSearchStrings(
63
+ [search, options.queryString],
64
+ 'append',
65
+ );
66
+ return `${getBaseURLForLocale(locale)}${finalSearch}${hash}`;
67
+ },
68
+ getLabel: (locale: string) => {
69
+ return getLocaleConfig(locale).label;
70
+ },
71
+ getLang: (locale: string) => {
72
+ return getLocaleConfig(locale).htmlLang;
73
+ },
74
+ };
75
+ }
76
+
20
77
  export default function LocaleDropdownNavbarItem({
21
78
  mobile,
22
79
  dropdownItemsBefore,
23
80
  dropdownItemsAfter,
24
- queryString = '',
81
+ queryString,
25
82
  ...props
26
83
  }: Props): ReactNode {
84
+ const utils = useLocaleDropdownUtils();
85
+
27
86
  const {
28
- i18n: {currentLocale, locales, localeConfigs},
87
+ i18n: {currentLocale, locales},
29
88
  } = useDocusaurusContext();
30
- const alternatePageUtils = useAlternatePageUtils();
31
- const {search, hash} = useLocation();
32
-
33
89
  const localeItems = locales.map((locale): LinkLikeNavbarItemProps => {
34
- const baseTo = `pathname://${alternatePageUtils.createUrl({
35
- locale,
36
- fullyQualified: false,
37
- })}`;
38
- // preserve ?search#hash suffix on locale switches
39
- const to = `${baseTo}${search}${hash}${queryString}`;
40
90
  return {
41
- label: localeConfigs[locale]!.label,
42
- lang: localeConfigs[locale]!.htmlLang,
43
- to,
91
+ label: utils.getLabel(locale),
92
+ lang: utils.getLang(locale),
93
+ to: utils.getURL(locale, {queryString}),
44
94
  target: '_self',
45
95
  autoAddBaseUrl: false,
46
96
  className:
@@ -65,7 +115,7 @@ export default function LocaleDropdownNavbarItem({
65
115
  id: 'theme.navbar.mobileLanguageDropdown.label',
66
116
  description: 'The label for the mobile language switcher dropdown',
67
117
  })
68
- : localeConfigs[currentLocale]!.label;
118
+ : utils.getLabel(currentLocale);
69
119
 
70
120
  return (
71
121
  <DropdownNavbarItem
@@ -7,6 +7,7 @@
7
7
 
8
8
  import React, {cloneElement, type ReactElement, type ReactNode} from 'react';
9
9
  import clsx from 'clsx';
10
+ import {ThemeClassNames} from '@docusaurus/theme-common';
10
11
  import {
11
12
  useScrollPositionBlocker,
12
13
  useTabs,
@@ -143,7 +144,14 @@ function TabContent({
143
144
  function TabsComponent(props: Props): ReactNode {
144
145
  const tabs = useTabs(props);
145
146
  return (
146
- <div className={clsx('tabs-container', styles.tabList)}>
147
+ <div
148
+ className={clsx(
149
+ ThemeClassNames.tabs.container,
150
+ // former name kept for backward compatibility
151
+ // see https://github.com/facebook/docusaurus/pull/4086
152
+ 'tabs-container',
153
+ styles.tabList,
154
+ )}>
147
155
  <TabList {...tabs} {...props} />
148
156
  <TabContent {...tabs} {...props} />
149
157
  </div>
@@ -1040,7 +1040,9 @@ declare module '@theme/SkipToContent' {
1040
1040
  declare module '@theme/MDXComponents/A' {
1041
1041
  import type {ComponentProps, ReactNode} from 'react';
1042
1042
 
1043
- export interface Props extends ComponentProps<'a'> {}
1043
+ export interface Props extends ComponentProps<'a'> {
1044
+ 'data-footnote-ref'?: true;
1045
+ }
1044
1046
 
1045
1047
  export default function MDXA(props: Props): ReactNode;
1046
1048
  }
@@ -1892,6 +1894,14 @@ declare module '@theme/Icon/Socials/Twitch' {
1892
1894
  export default function Twitch(props: Props): ReactNode;
1893
1895
  }
1894
1896
 
1897
+ declare module '@theme/Icon/Socials/Email' {
1898
+ import type {ComponentProps, ReactNode} from 'react';
1899
+
1900
+ export interface Props extends ComponentProps<'svg'> {}
1901
+
1902
+ export default function Email(props: Props): ReactNode;
1903
+ }
1904
+
1895
1905
  declare module '@theme/Icon/Socials/Mastodon' {
1896
1906
  import type {ComponentProps, ReactNode} from 'react';
1897
1907
 
@@ -1,14 +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 ReactNode} from 'react';
9
- import Link from '@docusaurus/Link';
10
- import type {Props} from '@theme/MDXComponents/A';
11
-
12
- export default function MDXA(props: Props): ReactNode {
13
- return <Link {...props} />;
14
- }