@docusaurus/theme-classic 2.0.0-beta.17 → 2.0.0-beta.18

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 (184) hide show
  1. package/lib/getSwizzleConfig.js +113 -2
  2. package/lib/index.js +7 -12
  3. package/lib/theme-classic.d.ts +286 -60
  4. package/lib/translations.js +12 -2
  5. package/lib/validateThemeConfig.js +1 -1
  6. package/lib-next/theme/BackToTopButton/index.js +1 -3
  7. package/lib-next/theme/BlogArchivePage/index.js +14 -10
  8. package/lib-next/theme/BlogListPage/index.js +34 -13
  9. package/lib-next/theme/BlogPostItem/index.js +6 -6
  10. package/lib-next/theme/BlogPostPage/index.js +56 -45
  11. package/lib-next/theme/BlogTagsListPage/index.js +16 -12
  12. package/lib-next/theme/BlogTagsPostsPage/index.js +40 -33
  13. package/lib-next/theme/CodeBlock/CopyButton/index.js +60 -0
  14. package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +66 -0
  15. package/lib-next/theme/CodeBlock/index.js +4 -36
  16. package/lib-next/theme/CodeBlock/styles.module.css +2 -22
  17. package/lib-next/theme/ColorModeToggle/index.js +36 -57
  18. package/lib-next/theme/ColorModeToggle/styles.module.css +8 -24
  19. package/lib-next/theme/DocBreadcrumbs/index.js +28 -11
  20. package/lib-next/theme/DocBreadcrumbs/styles.module.css +2 -17
  21. package/lib-next/theme/DocCard/index.js +17 -15
  22. package/lib-next/theme/DocCard/styles.module.css +8 -17
  23. package/lib-next/theme/DocCardList/index.js +15 -3
  24. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +27 -6
  25. package/lib-next/theme/DocItem/index.js +84 -66
  26. package/lib-next/theme/DocPage/index.js +88 -89
  27. package/lib-next/theme/DocPage/styles.module.css +0 -4
  28. package/lib-next/theme/DocSidebar/Desktop/CollapseButton/index.js +34 -0
  29. package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +44 -0
  30. package/lib-next/theme/DocSidebar/Desktop/Content/index.js +46 -0
  31. package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +17 -0
  32. package/lib-next/theme/DocSidebar/Desktop/index.js +34 -0
  33. package/lib-next/theme/DocSidebar/Desktop/styles.module.css +50 -0
  34. package/lib-next/theme/DocSidebar/Mobile/index.js +49 -0
  35. package/lib-next/theme/DocSidebar/index.js +6 -113
  36. package/lib-next/theme/DocSidebarItem/index.js +14 -13
  37. package/lib-next/theme/DocSidebarItem/styles.module.css +4 -0
  38. package/lib-next/theme/DocTagDocListPage/index.js +38 -31
  39. package/lib-next/theme/DocTagsListPage/index.js +21 -16
  40. package/lib-next/theme/Footer/Copyright/index.js +18 -0
  41. package/lib-next/theme/Footer/Layout/index.js +26 -0
  42. package/lib-next/theme/Footer/LinkItem/index.js +33 -0
  43. package/lib-next/theme/Footer/Links/MultiColumn/index.js +47 -0
  44. package/lib-next/theme/Footer/Links/Simple/index.js +41 -0
  45. package/lib-next/theme/Footer/Links/index.js +17 -0
  46. package/lib-next/theme/Footer/Logo/index.js +38 -0
  47. package/lib-next/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
  48. package/lib-next/theme/Footer/index.js +11 -163
  49. package/lib-next/theme/Heading/index.js +6 -4
  50. package/lib-next/theme/IconExternalLink/styles.module.css +0 -2
  51. package/lib-next/theme/Layout/index.js +15 -10
  52. package/lib-next/theme/LayoutProviders/index.js +5 -4
  53. package/lib-next/theme/MDXComponents/A.js +11 -0
  54. package/lib-next/theme/MDXComponents/Code.js +28 -0
  55. package/lib-next/theme/MDXComponents/Details.js +20 -0
  56. package/lib-next/theme/MDXComponents/Head.js +26 -0
  57. package/lib-next/theme/MDXComponents/Heading.js +11 -0
  58. package/lib-next/theme/MDXComponents/Img.js +24 -0
  59. package/lib-next/theme/MDXComponents/Img.module.css +10 -0
  60. package/lib-next/theme/MDXComponents/Pre.js +18 -0
  61. package/lib-next/theme/MDXComponents/Ul.js +23 -0
  62. package/{src/theme/MDXComponents/styles.css → lib-next/theme/MDXComponents/Ul.module.css} +1 -5
  63. package/lib-next/theme/MDXComponents/index.js +22 -71
  64. package/lib-next/theme/MDXContent/index.js +12 -0
  65. package/lib-next/theme/MDXPage/index.js +33 -28
  66. package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
  67. package/lib-next/theme/Navbar/Content/index.js +70 -0
  68. package/lib-next/theme/Navbar/Content/styles.module.css +15 -0
  69. package/lib-next/theme/Navbar/Layout/index.js +54 -0
  70. package/{src/theme/Navbar → lib-next/theme/Navbar/Layout}/styles.module.css +0 -13
  71. package/lib-next/theme/Navbar/Logo/index.js +17 -0
  72. package/lib-next/theme/Navbar/MobileSidebar/Header/index.js +33 -0
  73. package/lib-next/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
  74. package/lib-next/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +33 -0
  75. package/lib-next/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +36 -0
  76. package/lib-next/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
  77. package/lib-next/theme/Navbar/MobileSidebar/index.js +31 -0
  78. package/lib-next/theme/Navbar/index.js +6 -271
  79. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +2 -6
  80. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +10 -2
  81. package/lib-next/theme/NavbarItem/NavbarNavLink.js +8 -12
  82. package/lib-next/theme/NotFound.js +38 -33
  83. package/lib-next/theme/{LayoutHead → SiteMetadata}/index.js +11 -26
  84. package/lib-next/theme/TOCCollapsible/index.js +1 -3
  85. package/lib-next/theme/Tabs/__tests__/index.test.js +5 -5
  86. package/lib-next/theme/Tabs/index.js +2 -2
  87. package/lib-next/theme/Tag/index.js +4 -4
  88. package/lib-next/theme/ThemedImage/index.js +3 -3
  89. package/package.json +17 -17
  90. package/src/getSwizzleConfig.ts +122 -1
  91. package/src/index.ts +10 -12
  92. package/src/theme/BackToTopButton/index.tsx +1 -3
  93. package/src/theme/BlogArchivePage/index.tsx +18 -17
  94. package/src/theme/BlogLayout/index.tsx +1 -1
  95. package/src/theme/BlogListPage/index.tsx +32 -13
  96. package/src/theme/BlogPostItem/index.tsx +6 -6
  97. package/src/theme/BlogPostPage/index.tsx +55 -48
  98. package/src/theme/BlogTagsListPage/index.tsx +16 -12
  99. package/src/theme/BlogTagsPostsPage/index.tsx +39 -32
  100. package/src/theme/CodeBlock/CopyButton/index.tsx +66 -0
  101. package/src/theme/CodeBlock/CopyButton/styles.module.css +66 -0
  102. package/src/theme/CodeBlock/index.tsx +6 -38
  103. package/src/theme/CodeBlock/styles.module.css +2 -22
  104. package/src/theme/ColorModeToggle/index.tsx +36 -61
  105. package/src/theme/ColorModeToggle/styles.module.css +8 -24
  106. package/src/theme/DocBreadcrumbs/index.tsx +29 -10
  107. package/src/theme/DocBreadcrumbs/styles.module.css +2 -17
  108. package/src/theme/DocCard/index.tsx +24 -17
  109. package/src/theme/DocCard/styles.module.css +8 -17
  110. package/src/theme/DocCardList/index.tsx +14 -3
  111. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +31 -4
  112. package/src/theme/DocItem/index.tsx +71 -55
  113. package/src/theme/DocPage/index.tsx +89 -90
  114. package/src/theme/DocPage/styles.module.css +0 -4
  115. package/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx +38 -0
  116. package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +44 -0
  117. package/src/theme/DocSidebar/Desktop/Content/index.tsx +55 -0
  118. package/src/theme/DocSidebar/Desktop/Content/styles.module.css +17 -0
  119. package/src/theme/DocSidebar/Desktop/index.tsx +38 -0
  120. package/src/theme/DocSidebar/Desktop/styles.module.css +50 -0
  121. package/src/theme/DocSidebar/Mobile/index.tsx +54 -0
  122. package/src/theme/DocSidebar/index.tsx +6 -121
  123. package/src/theme/DocSidebarItem/index.tsx +15 -16
  124. package/src/theme/DocSidebarItem/styles.module.css +4 -0
  125. package/src/theme/DocTagDocListPage/index.tsx +38 -30
  126. package/src/theme/DocTagsListPage/index.tsx +21 -16
  127. package/src/theme/DocVersionBanner/index.tsx +3 -4
  128. package/src/theme/Footer/Copyright/index.tsx +20 -0
  129. package/src/theme/Footer/Layout/index.tsx +34 -0
  130. package/src/theme/Footer/LinkItem/index.tsx +36 -0
  131. package/src/theme/Footer/Links/MultiColumn/index.tsx +51 -0
  132. package/src/theme/Footer/Links/Simple/index.tsx +42 -0
  133. package/src/theme/Footer/Links/index.tsx +21 -0
  134. package/src/theme/Footer/Logo/index.tsx +41 -0
  135. package/src/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
  136. package/src/theme/Footer/index.tsx +12 -186
  137. package/src/theme/Heading/index.tsx +6 -4
  138. package/src/theme/IconExternalLink/styles.module.css +0 -2
  139. package/src/theme/Layout/index.tsx +15 -10
  140. package/src/theme/LayoutProviders/index.tsx +5 -4
  141. package/src/theme/MDXComponents/A.tsx +14 -0
  142. package/src/theme/MDXComponents/Code.tsx +37 -0
  143. package/src/theme/MDXComponents/Details.tsx +26 -0
  144. package/src/theme/MDXComponents/Head.tsx +29 -0
  145. package/src/theme/MDXComponents/Heading.tsx +14 -0
  146. package/src/theme/MDXComponents/Img.module.css +10 -0
  147. package/src/theme/MDXComponents/Img.tsx +26 -0
  148. package/src/theme/MDXComponents/Pre.tsx +22 -0
  149. package/{lib-next/theme/MDXComponents/styles.css → src/theme/MDXComponents/Ul.module.css} +1 -5
  150. package/src/theme/MDXComponents/Ul.tsx +28 -0
  151. package/src/theme/MDXComponents/index.tsx +23 -80
  152. package/src/theme/MDXContent/index.tsx +15 -0
  153. package/src/theme/MDXPage/index.tsx +33 -28
  154. package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
  155. package/src/theme/Navbar/Content/index.tsx +81 -0
  156. package/src/theme/Navbar/Content/styles.module.css +15 -0
  157. package/src/theme/Navbar/Layout/index.tsx +57 -0
  158. package/{lib-next/theme/Navbar → src/theme/Navbar/Layout}/styles.module.css +0 -13
  159. package/src/theme/Navbar/Logo/index.tsx +19 -0
  160. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
  161. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
  162. package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +38 -0
  163. package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
  164. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
  165. package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
  166. package/src/theme/Navbar/index.tsx +6 -286
  167. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +2 -2
  168. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +11 -2
  169. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +1 -1
  170. package/src/theme/NavbarItem/NavbarNavLink.tsx +3 -7
  171. package/src/theme/NavbarItem/index.tsx +3 -4
  172. package/src/theme/NotFound.tsx +38 -33
  173. package/src/theme/{LayoutHead → SiteMetadata}/index.tsx +11 -25
  174. package/src/theme/TOCCollapsible/index.tsx +1 -3
  175. package/src/theme/Tabs/index.tsx +5 -6
  176. package/src/theme/Tag/index.tsx +4 -4
  177. package/src/theme/ThemedImage/index.tsx +4 -3
  178. package/src/theme-classic.d.ts +286 -60
  179. package/src/translations.ts +12 -6
  180. package/src/validateThemeConfig.ts +6 -6
  181. package/lib-next/theme/DocSidebar/styles.module.css +0 -107
  182. package/lib-next/theme/Seo/index.js +0 -40
  183. package/src/theme/DocSidebar/styles.module.css +0 -107
  184. package/src/theme/Seo/index.tsx +0 -49
@@ -9,15 +9,15 @@ import Head from '@docusaurus/Head';
9
9
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
10
  import useBaseUrl from '@docusaurus/useBaseUrl';
11
11
  import SearchMetadata from '@theme/SearchMetadata';
12
- import Seo from '@theme/Seo';
13
12
  import {
13
+ PageMetadata,
14
14
  DEFAULT_SEARCH_TAG,
15
- useTitleFormatter,
16
15
  useAlternatePageUtils,
17
16
  useThemeConfig,
18
17
  keyboardFocusedClassName,
19
18
  } from '@docusaurus/theme-common';
20
- import {useLocation} from '@docusaurus/router'; // Useful for SEO
19
+ import {useLocation} from '@docusaurus/router'; // TODO move to SiteMetadataDefaults or theme-common ?
20
+ // Useful for i18n/SEO
21
21
  // See https://developers.google.com/search/docs/advanced/crawling/localized-versions
22
22
  // See https://github.com/facebook/docusaurus/issues/3317
23
23
 
@@ -59,7 +59,7 @@ function useDefaultCanonicalUrl() {
59
59
  } = useDocusaurusContext();
60
60
  const {pathname} = useLocation();
61
61
  return siteUrl + useBaseUrl(pathname);
62
- }
62
+ } // TODO move to SiteMetadataDefaults or theme-common ?
63
63
 
64
64
  function CanonicalUrlHeaders({permalink}) {
65
65
  const {
@@ -77,44 +77,29 @@ function CanonicalUrlHeaders({permalink}) {
77
77
  );
78
78
  }
79
79
 
80
- export default function LayoutHead(props) {
80
+ export default function SiteMetadata() {
81
81
  const {
82
- siteConfig: {favicon},
83
- i18n: {currentLocale, localeConfigs},
84
- } = useDocusaurusContext();
82
+ i18n: {currentLocale},
83
+ } = useDocusaurusContext(); // TODO maybe move these 2 themeConfig to siteConfig?
84
+ // These seems useful for other themes as well
85
+
85
86
  const {metadata, image: defaultImage} = useThemeConfig();
86
- const {title, description, image, keywords, searchMetadata} = props;
87
- const faviconUrl = useBaseUrl(favicon);
88
- const pageTitle = useTitleFormatter(title);
89
- const {htmlLang, direction: htmlDir} = localeConfigs[currentLocale];
90
87
  return (
91
88
  <>
92
89
  <Head>
93
- <html lang={htmlLang} dir={htmlDir} />
94
- {favicon && <link rel="icon" href={faviconUrl} />}
95
- <title>{pageTitle}</title>
96
- <meta property="og:title" content={pageTitle} />
97
90
  <meta name="twitter:card" content="summary_large_image" />
98
91
  {/* The keyboard focus class name need to be applied when SSR so links
99
92
  are outlined when JS is disabled */}
100
93
  <body className={keyboardFocusedClassName} />
101
94
  </Head>
102
95
 
103
- {/* image can override the default image */}
104
- {defaultImage && <Seo image={defaultImage} />}
105
- {image && <Seo image={image} />}
106
-
107
- <Seo description={description} keywords={keywords} />
96
+ {defaultImage && <PageMetadata image={defaultImage} />}
108
97
 
109
98
  <CanonicalUrlHeaders />
110
99
 
111
100
  <AlternateLangHeaders />
112
101
 
113
- <SearchMetadata
114
- tag={DEFAULT_SEARCH_TAG}
115
- locale={currentLocale}
116
- {...searchMetadata}
117
- />
102
+ <SearchMetadata tag={DEFAULT_SEARCH_TAG} locale={currentLocale} />
118
103
 
119
104
  <Head // it's important to have an additional <Head> element here,
120
105
  // as it allows react-helmet to override values set in previous <Head>
@@ -23,9 +23,7 @@ export default function TOCCollapsible({
23
23
  <div
24
24
  className={clsx(
25
25
  styles.tocCollapsible,
26
- {
27
- [styles.tocCollapsibleExpanded]: !collapsed,
28
- },
26
+ !collapsed && styles.tocCollapsibleExpanded,
29
27
  className,
30
28
  )}>
31
29
  <button
@@ -13,7 +13,7 @@ import {
13
13
  ScrollControllerProvider,
14
14
  } from '@docusaurus/theme-common';
15
15
  describe('Tabs', () => {
16
- test('Should reject bad Tabs child', () => {
16
+ it('rejects bad Tabs child', () => {
17
17
  expect(() => {
18
18
  renderer.create(
19
19
  <Tabs>
@@ -25,7 +25,7 @@ describe('Tabs', () => {
25
25
  `"Docusaurus error: Bad <Tabs> child <div>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique \\"value\\" prop."`,
26
26
  );
27
27
  });
28
- test('Should reject bad Tabs defaultValue', () => {
28
+ it('rejects bad Tabs defaultValue', () => {
29
29
  expect(() => {
30
30
  renderer.create(
31
31
  <Tabs defaultValue="bad">
@@ -37,7 +37,7 @@ describe('Tabs', () => {
37
37
  `"Docusaurus error: The <Tabs> has a defaultValue \\"bad\\" but none of its children has the corresponding value. Available values are: v1, v2. If you intend to show no default tab, use defaultValue={null} instead."`,
38
38
  );
39
39
  });
40
- test('Should reject duplicate values', () => {
40
+ it('rejects duplicate values', () => {
41
41
  expect(() => {
42
42
  renderer.create(
43
43
  <Tabs>
@@ -53,7 +53,7 @@ describe('Tabs', () => {
53
53
  `"Docusaurus error: Duplicate values \\"v1, v2\\" found in <Tabs>. Every value needs to be unique."`,
54
54
  );
55
55
  });
56
- test('Should accept valid Tabs config', () => {
56
+ it('accepts valid Tabs config', () => {
57
57
  expect(() => {
58
58
  renderer.create(
59
59
  <ScrollControllerProvider>
@@ -120,7 +120,7 @@ describe('Tabs', () => {
120
120
  }).not.toThrow(); // TODO Better Jest infrastructure to mock the Layout
121
121
  }); // https://github.com/facebook/docusaurus/issues/5729
122
122
 
123
- test('Should accept dynamic Tabs with number values', () => {
123
+ it('accepts dynamic Tabs with number values', () => {
124
124
  expect(() => {
125
125
  const tabs = ['Apple', 'Banana', 'Carrot'];
126
126
  renderer.create(
@@ -4,7 +4,7 @@
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, {useState, cloneElement, Children, isValidElement} from 'react';
7
+ import React, {useState, cloneElement, isValidElement} from 'react';
8
8
  import useIsBrowser from '@docusaurus/useIsBrowser';
9
9
  import {
10
10
  useScrollPositionBlocker,
@@ -28,7 +28,7 @@ function TabsComponent(props) {
28
28
  groupId,
29
29
  className,
30
30
  } = props;
31
- const children = Children.map(props.children, (child) => {
31
+ const children = React.Children.map(props.children, (child) => {
32
32
  if (isValidElement(child) && isTabItem(child)) {
33
33
  return child;
34
34
  } // child.type.name will give non-sensical values in prod because of
@@ -13,10 +13,10 @@ export default function Tag(props) {
13
13
  return (
14
14
  <Link
15
15
  href={permalink}
16
- className={clsx(styles.tag, {
17
- [styles.tagRegular]: !count,
18
- [styles.tagWithCount]: count,
19
- })}>
16
+ className={clsx(
17
+ styles.tag,
18
+ count ? styles.tagWithCount : styles.tagRegular,
19
+ )}>
20
20
  {name}
21
21
  {count && <span>{count}</span>}
22
22
  </Link>
@@ -11,9 +11,9 @@ import {useColorMode} from '@docusaurus/theme-common';
11
11
  import styles from './styles.module.css';
12
12
  export default function ThemedImage(props) {
13
13
  const isBrowser = useIsBrowser();
14
- const {isDarkTheme} = useColorMode();
15
- const {sources, className, alt = '', ...propsRest} = props;
16
- const clientThemes = isDarkTheme ? ['dark'] : ['light'];
14
+ const {colorMode} = useColorMode();
15
+ const {sources, className, alt, ...propsRest} = props;
16
+ const clientThemes = colorMode === 'dark' ? ['dark'] : ['light'];
17
17
  const renderedSourceNames = isBrowser
18
18
  ? clientThemes // We need to render both images on the server to avoid flash
19
19
  : // See https://github.com/facebook/docusaurus/pull/3730
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "2.0.0-beta.17",
3
+ "version": "2.0.0-beta.18",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -21,29 +21,29 @@
21
21
  "format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
22
22
  },
23
23
  "dependencies": {
24
- "@docusaurus/core": "2.0.0-beta.17",
25
- "@docusaurus/plugin-content-blog": "2.0.0-beta.17",
26
- "@docusaurus/plugin-content-docs": "2.0.0-beta.17",
27
- "@docusaurus/plugin-content-pages": "2.0.0-beta.17",
28
- "@docusaurus/theme-common": "2.0.0-beta.17",
29
- "@docusaurus/theme-translations": "2.0.0-beta.17",
30
- "@docusaurus/utils": "2.0.0-beta.17",
31
- "@docusaurus/utils-common": "2.0.0-beta.17",
32
- "@docusaurus/utils-validation": "2.0.0-beta.17",
24
+ "@docusaurus/core": "2.0.0-beta.18",
25
+ "@docusaurus/plugin-content-blog": "2.0.0-beta.18",
26
+ "@docusaurus/plugin-content-docs": "2.0.0-beta.18",
27
+ "@docusaurus/plugin-content-pages": "2.0.0-beta.18",
28
+ "@docusaurus/theme-common": "2.0.0-beta.18",
29
+ "@docusaurus/theme-translations": "2.0.0-beta.18",
30
+ "@docusaurus/utils": "2.0.0-beta.18",
31
+ "@docusaurus/utils-common": "2.0.0-beta.18",
32
+ "@docusaurus/utils-validation": "2.0.0-beta.18",
33
33
  "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
36
- "infima": "0.2.0-alpha.37",
36
+ "infima": "0.2.0-alpha.38",
37
37
  "lodash": "^4.17.21",
38
- "postcss": "^8.4.7",
39
- "prism-react-renderer": "^1.2.1",
38
+ "postcss": "^8.4.12",
39
+ "prism-react-renderer": "^1.3.1",
40
40
  "prismjs": "^1.27.0",
41
41
  "react-router-dom": "^5.2.0",
42
- "rtlcss": "^3.3.0"
42
+ "rtlcss": "^3.5.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "2.0.0-beta.17",
46
- "@docusaurus/types": "2.0.0-beta.17",
45
+ "@docusaurus/module-type-aliases": "2.0.0-beta.18",
46
+ "@docusaurus/types": "2.0.0-beta.18",
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": "0032c0b0480083227af2e1b4da2d3ee6ce992403"
62
+ "gitHead": "1a945d06993d53376e61bed2c942799fe07dc336"
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',
@@ -85,6 +136,76 @@ export default function getSwizzleConfig(): SwizzleConfig {
85
136
  description:
86
137
  'The MDX components to use for rendering MDX files. Meant to be ejected.',
87
138
  },
139
+ 'MDXComponents/A': {
140
+ actions: {
141
+ eject: 'safe',
142
+ wrap: 'safe',
143
+ },
144
+ description:
145
+ 'The component used to render <a> tags and Markdown links in MDX',
146
+ },
147
+ 'MDXComponents/Code': {
148
+ actions: {
149
+ eject: 'safe',
150
+ wrap: 'safe',
151
+ },
152
+ description:
153
+ 'The component used to render <code> tags and Markdown code blocks in MDX',
154
+ },
155
+ 'MDXComponents/Details': {
156
+ actions: {
157
+ eject: 'safe',
158
+ wrap: 'safe',
159
+ },
160
+ description: 'The component used to render <details> tags in MDX',
161
+ },
162
+ 'MDXComponents/Head': {
163
+ actions: {
164
+ eject: 'forbidden',
165
+ wrap: 'forbidden',
166
+ },
167
+ description:
168
+ 'Technical component used to assign metadata (generally for SEO purpose) to the current MDX document',
169
+ },
170
+ 'MDXComponents/Heading': {
171
+ actions: {
172
+ eject: 'safe',
173
+ wrap: 'safe',
174
+ },
175
+ description:
176
+ 'The component used to render heading tags (<h1>, <h2>...) and Markdown headings in MDX',
177
+ },
178
+ 'MDXComponents/Img': {
179
+ actions: {
180
+ eject: 'safe',
181
+ wrap: 'safe',
182
+ },
183
+ description:
184
+ 'The component used to render <img> tags and Markdown images in MDX',
185
+ },
186
+ 'MDXComponents/Pre': {
187
+ actions: {
188
+ eject: 'safe',
189
+ wrap: 'safe',
190
+ },
191
+ description: 'The component used to render <pre> tags in MDX',
192
+ },
193
+ 'MDXComponents/Ul': {
194
+ actions: {
195
+ eject: 'safe',
196
+ wrap: 'safe',
197
+ },
198
+ description:
199
+ 'The component used to render <ul> tags and Markdown unordered lists in MDX',
200
+ },
201
+ MDXContent: {
202
+ actions: {
203
+ eject: 'safe',
204
+ wrap: 'safe',
205
+ },
206
+ description:
207
+ 'A component wrapping all MDX content and providing the MDXComponents to the MDX context',
208
+ },
88
209
  // TODO should probably not even appear here
89
210
  'NavbarItem/utils': {
90
211
  actions: {
package/src/index.ts CHANGED
@@ -5,10 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {LoadContext, Plugin, PostCssOptions} from '@docusaurus/types';
8
+ import type {LoadContext, Plugin} from '@docusaurus/types';
9
9
  import type {ThemeConfig} from '@docusaurus/theme-common';
10
10
  import {getTranslationFiles, translateThemeConfig} from './translations';
11
- import path from 'path';
12
11
  import {createRequire} from 'module';
13
12
  import type {Plugin as PostCssPlugin} from 'postcss';
14
13
  import rtlcss from 'rtlcss';
@@ -97,27 +96,26 @@ export default function docusaurusThemeClassic(
97
96
  options: Options,
98
97
  ): Plugin<void> {
99
98
  const {
100
- siteConfig: {themeConfig: roughlyTypedThemeConfig},
101
99
  i18n: {currentLocale, localeConfigs},
102
100
  } = context;
103
- const themeConfig = (roughlyTypedThemeConfig || {}) as ThemeConfig;
101
+ const themeConfig = context.siteConfig.themeConfig as ThemeConfig;
104
102
  const {
105
103
  announcementBar,
106
104
  colorMode,
107
- prism: {additionalLanguages = []} = {},
105
+ prism: {additionalLanguages},
108
106
  } = themeConfig;
109
- const {customCss} = options || {};
110
- const {direction} = localeConfigs[currentLocale];
107
+ const {customCss} = options ?? {};
108
+ const {direction} = localeConfigs[currentLocale]!;
111
109
 
112
110
  return {
113
111
  name: 'docusaurus-theme-classic',
114
112
 
115
113
  getThemePath() {
116
- return path.join(__dirname, '../lib-next/theme');
114
+ return '../lib-next/theme';
117
115
  },
118
116
 
119
117
  getTypeScriptThemePath() {
120
- return path.resolve(__dirname, '../src/theme');
118
+ return '../src/theme';
121
119
  },
122
120
 
123
121
  getTranslationFiles: async () => getTranslationFiles({themeConfig}),
@@ -138,8 +136,8 @@ export default function docusaurusThemeClassic(
138
136
  getClientModules() {
139
137
  const modules = [
140
138
  require.resolve(getInfimaCSSFile(direction)),
141
- path.resolve(__dirname, './prism-include-languages'),
142
- path.resolve(__dirname, './admonitions.css'),
139
+ './prism-include-languages',
140
+ './admonitions.css',
143
141
  ];
144
142
 
145
143
  if (customCss) {
@@ -171,7 +169,7 @@ export default function docusaurusThemeClassic(
171
169
  };
172
170
  },
173
171
 
174
- configurePostCss(postCssOptions: PostCssOptions) {
172
+ configurePostCss(postCssOptions) {
175
173
  if (direction === 'rtl') {
176
174
  const resolvedInfimaFile = require.resolve(getInfimaCSSFile(direction));
177
175
  const plugin: PostCssPlugin = {
@@ -132,9 +132,7 @@ export default function BackToTopButton(): JSX.Element {
132
132
  'clean-btn',
133
133
  ThemeClassNames.common.backToTopButton,
134
134
  styles.backToTopButton,
135
- {
136
- [styles.backToTopButtonShow]: show,
137
- },
135
+ show && styles.backToTopButtonShow,
138
136
  )}
139
137
  type="button"
140
138
  onClick={() => smoothScrollTop()}
@@ -10,6 +10,7 @@ import Layout from '@theme/Layout';
10
10
  import Link from '@docusaurus/Link';
11
11
  import type {ArchiveBlogPost, Props} from '@theme/BlogArchivePage';
12
12
  import {translate} from '@docusaurus/Translate';
13
+ import {PageMetadata} from '@docusaurus/theme-common';
13
14
 
14
15
  type YearProp = {
15
16
  year: string;
@@ -50,14 +51,11 @@ function YearsSection({years}: {years: YearProp[]}) {
50
51
  }
51
52
 
52
53
  function listPostsByYears(blogPosts: readonly ArchiveBlogPost[]): YearProp[] {
53
- const postsByYear: Map<string, ArchiveBlogPost[]> = blogPosts.reduceRight(
54
- (posts, post) => {
55
- const year = post.metadata.date.split('-')[0];
56
- const yearPosts = posts.get(year) || [];
57
- return posts.set(year, [post, ...yearPosts]);
58
- },
59
- new Map(),
60
- );
54
+ const postsByYear = blogPosts.reduceRight((posts, post) => {
55
+ const year = post.metadata.date.split('-')[0]!;
56
+ const yearPosts = posts.get(year) ?? [];
57
+ return posts.set(year, [post, ...yearPosts]);
58
+ }, new Map<string, ArchiveBlogPost[]>());
61
59
 
62
60
  return Array.from(postsByYear, ([year, posts]) => ({
63
61
  year,
@@ -78,14 +76,17 @@ export default function BlogArchive({archive}: Props): JSX.Element {
78
76
  });
79
77
  const years = listPostsByYears(archive.blogPosts);
80
78
  return (
81
- <Layout title={title} description={description}>
82
- <header className="hero hero--primary">
83
- <div className="container">
84
- <h1 className="hero__title">{title}</h1>
85
- <p className="hero__subtitle">{description}</p>
86
- </div>
87
- </header>
88
- <main>{years.length > 0 && <YearsSection years={years} />}</main>
89
- </Layout>
79
+ <>
80
+ <PageMetadata title={title} description={description} />
81
+ <Layout>
82
+ <header className="hero hero--primary">
83
+ <div className="container">
84
+ <h1 className="hero__title">{title}</h1>
85
+ <p className="hero__subtitle">{description}</p>
86
+ </div>
87
+ </header>
88
+ <main>{years.length > 0 && <YearsSection years={years} />}</main>
89
+ </Layout>
90
+ </>
90
91
  );
91
92
  }
@@ -22,7 +22,7 @@ export default function BlogLayout(props: Props): JSX.Element {
22
22
  <div className="row">
23
23
  {hasSidebar && (
24
24
  <aside className="col col--3">
25
- <BlogSidebar sidebar={sidebar!} />
25
+ <BlogSidebar sidebar={sidebar} />
26
26
  </aside>
27
27
  )}
28
28
  <main
@@ -12,28 +12,34 @@ import BlogLayout from '@theme/BlogLayout';
12
12
  import BlogPostItem from '@theme/BlogPostItem';
13
13
  import BlogListPaginator from '@theme/BlogListPaginator';
14
14
  import type {Props} from '@theme/BlogListPage';
15
- import {ThemeClassNames} from '@docusaurus/theme-common';
15
+ import {
16
+ PageMetadata,
17
+ HtmlClassNameProvider,
18
+ ThemeClassNames,
19
+ } from '@docusaurus/theme-common';
20
+ import SearchMetadata from '@theme/SearchMetadata';
21
+ import clsx from 'clsx';
16
22
 
17
- export default function BlogListPage(props: Props): JSX.Element {
18
- const {metadata, items, sidebar} = props;
23
+ function BlogListPageMetadata(props: Props): JSX.Element {
24
+ const {metadata} = props;
19
25
  const {
20
26
  siteConfig: {title: siteTitle},
21
27
  } = useDocusaurusContext();
22
28
  const {blogDescription, blogTitle, permalink} = metadata;
23
29
  const isBlogOnlyMode = permalink === '/';
24
30
  const title = isBlogOnlyMode ? siteTitle : blogTitle;
31
+ return (
32
+ <>
33
+ <PageMetadata title={title} description={blogDescription} />
34
+ <SearchMetadata tag="blog_posts_list" />
35
+ </>
36
+ );
37
+ }
25
38
 
39
+ function BlogListPageContent(props: Props): JSX.Element {
40
+ const {metadata, items, sidebar} = props;
26
41
  return (
27
- <BlogLayout
28
- title={title}
29
- description={blogDescription}
30
- wrapperClassName={ThemeClassNames.wrapper.blogPages}
31
- pageClassName={ThemeClassNames.page.blogListPage}
32
- searchMetadata={{
33
- // assign unique search tag to exclude this page from search results!
34
- tag: 'blog_posts_list',
35
- }}
36
- sidebar={sidebar}>
42
+ <BlogLayout sidebar={sidebar}>
37
43
  {items.map(({content: BlogPostContent}) => (
38
44
  <BlogPostItem
39
45
  key={BlogPostContent.metadata.permalink}
@@ -48,3 +54,16 @@ export default function BlogListPage(props: Props): JSX.Element {
48
54
  </BlogLayout>
49
55
  );
50
56
  }
57
+
58
+ export default function BlogListPage(props: Props): JSX.Element {
59
+ return (
60
+ <HtmlClassNameProvider
61
+ className={clsx(
62
+ ThemeClassNames.wrapper.blogPages,
63
+ ThemeClassNames.page.blogListPage,
64
+ )}>
65
+ <BlogListPageMetadata {...props} />
66
+ <BlogListPageContent {...props} />
67
+ </HtmlClassNameProvider>
68
+ );
69
+ }
@@ -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,14 +107,15 @@ 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) && (
115
114
  <footer
116
- className={clsx('row docusaurus-mt-lg', {
117
- [styles.blogPostDetailsFull]: isBlogPostPage,
118
- })}>
115
+ className={clsx(
116
+ 'row docusaurus-mt-lg',
117
+ isBlogPostPage && styles.blogPostDetailsFull,
118
+ )}>
119
119
  {tagsExists && (
120
120
  <div className={clsx('col', {'col--9': truncatedPost})}>
121
121
  <TagsListInline tags={tags} />