@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
@@ -143,7 +143,8 @@ function DocSidebarItemCategory({
143
143
  })}>
144
144
  <Link
145
145
  className={clsx('menu__link', {
146
- 'menu__link--sublist': collapsible && !href,
146
+ 'menu__link--sublist': collapsible,
147
+ 'menu__link--sublist-caret': !href,
147
148
  'menu__link--active': isActive,
148
149
  })}
149
150
  onClick={
@@ -163,6 +164,7 @@ function DocSidebarItemCategory({
163
164
  }
164
165
  }
165
166
  aria-current={isCurrentPage ? 'page' : undefined}
167
+ aria-expanded={collapsible ? !collapsed : undefined}
166
168
  href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
167
169
  {...props}>
168
170
  {label}
@@ -231,6 +233,7 @@ function DocSidebarItemLink({
231
233
  }) {
232
234
  const {href, label, className} = item;
233
235
  const isActive = isActiveSidebarItem(item, activePath);
236
+ const isInternalLink = isInternalUrl(href);
234
237
  return (
235
238
  <li
236
239
  className={clsx(
@@ -241,23 +244,21 @@ function DocSidebarItemLink({
241
244
  )}
242
245
  key={label}>
243
246
  <Link
244
- className={clsx('menu__link', {
245
- 'menu__link--active': isActive,
246
- })}
247
+ className={clsx(
248
+ 'menu__link',
249
+ !isInternalLink && styles.menuExternalLink,
250
+ {
251
+ 'menu__link--active': isActive,
252
+ },
253
+ )}
247
254
  aria-current={isActive ? 'page' : undefined}
248
255
  to={href}
249
- {...(isInternalUrl(href) && {
256
+ {...(isInternalLink && {
250
257
  onClick: onItemClick ? () => onItemClick(item) : undefined,
251
258
  })}
252
259
  {...props}>
253
- {isInternalUrl(href) ? (
254
- label
255
- ) : (
256
- <span>
257
- {label}
258
- <IconExternalLink />
259
- </span>
260
- )}
260
+ {label}
261
+ {!isInternalLink && <IconExternalLink />}
261
262
  </Link>
262
263
  </li>
263
264
  );
@@ -11,3 +11,7 @@
11
11
  var(--ifm-menu-link-padding-horizontal);
12
12
  }
13
13
  }
14
+
15
+ .menuExternalLink {
16
+ align-items: center;
17
+ }
@@ -7,10 +7,16 @@
7
7
  import React from 'react';
8
8
  import Layout from '@theme/Layout';
9
9
  import Link from '@docusaurus/Link';
10
- import {ThemeClassNames, usePluralForm} from '@docusaurus/theme-common';
10
+ import {
11
+ PageMetadata,
12
+ HtmlClassNameProvider,
13
+ ThemeClassNames,
14
+ usePluralForm,
15
+ } from '@docusaurus/theme-common';
11
16
  import Translate, {translate} from '@docusaurus/Translate';
17
+ import SearchMetadata from '@theme/SearchMetadata';
18
+ import clsx from 'clsx'; // Very simple pluralization: probably good enough for now
12
19
 
13
- // Very simple pluralization: probably good enough for now
14
20
  function useNDocsTaggedPlural() {
15
21
  const {selectMessage} = usePluralForm();
16
22
  return (count) =>
@@ -55,35 +61,36 @@ export default function DocTagDocListPage({tag}) {
55
61
  },
56
62
  );
57
63
  return (
58
- <Layout
59
- title={title}
60
- wrapperClassName={ThemeClassNames.wrapper.docsPages}
61
- pageClassName={ThemeClassNames.page.docsTagDocListPage}
62
- searchMetadata={{
63
- // assign unique search tag to exclude this page from search results!
64
- tag: 'doc_tag_doc_list',
65
- }}>
66
- <div className="container margin-vert--lg">
67
- <div className="row">
68
- <main className="col col--8 col--offset-2">
69
- <header className="margin-bottom--xl">
70
- <h1>{title}</h1>
71
- <Link href={tag.allTagsPath}>
72
- <Translate
73
- id="theme.tags.tagsPageLink"
74
- description="The label of the link targeting the tag list page">
75
- View All Tags
76
- </Translate>
77
- </Link>
78
- </header>
79
- <section className="margin-vert--lg">
80
- {tag.docs.map((doc) => (
81
- <DocItem key={doc.id} doc={doc} />
82
- ))}
83
- </section>
84
- </main>
64
+ <HtmlClassNameProvider
65
+ className={clsx(
66
+ ThemeClassNames.wrapper.docsPages,
67
+ ThemeClassNames.page.docsTagDocListPage,
68
+ )}>
69
+ <PageMetadata title={title} />
70
+ <SearchMetadata tag="doc_tag_doc_list" />
71
+ <Layout>
72
+ <div className="container margin-vert--lg">
73
+ <div className="row">
74
+ <main className="col col--8 col--offset-2">
75
+ <header className="margin-bottom--xl">
76
+ <h1>{title}</h1>
77
+ <Link href={tag.allTagsPath}>
78
+ <Translate
79
+ id="theme.tags.tagsPageLink"
80
+ description="The label of the link targeting the tag list page">
81
+ View All Tags
82
+ </Translate>
83
+ </Link>
84
+ </header>
85
+ <section className="margin-vert--lg">
86
+ {tag.docs.map((doc) => (
87
+ <DocItem key={doc.id} doc={doc} />
88
+ ))}
89
+ </section>
90
+ </main>
91
+ </div>
85
92
  </div>
86
- </div>
87
- </Layout>
93
+ </Layout>
94
+ </HtmlClassNameProvider>
88
95
  );
89
96
  }
@@ -7,29 +7,34 @@
7
7
  import React from 'react';
8
8
  import Layout from '@theme/Layout';
9
9
  import {
10
+ PageMetadata,
11
+ HtmlClassNameProvider,
10
12
  ThemeClassNames,
11
13
  translateTagsPageTitle,
12
14
  } from '@docusaurus/theme-common';
13
15
  import TagsListByLetter from '@theme/TagsListByLetter';
16
+ import SearchMetadata from '@theme/SearchMetadata';
17
+ import clsx from 'clsx';
14
18
  export default function DocTagsListPage({tags}) {
15
19
  const title = translateTagsPageTitle();
16
20
  return (
17
- <Layout
18
- title={title}
19
- wrapperClassName={ThemeClassNames.wrapper.docsPages}
20
- pageClassName={ThemeClassNames.page.docsTagsListPage}
21
- searchMetadata={{
22
- // assign unique search tag to exclude this page from search results!
23
- tag: 'doc_tags_list',
24
- }}>
25
- <div className="container margin-vert--lg">
26
- <div className="row">
27
- <main className="col col--8 col--offset-2">
28
- <h1>{title}</h1>
29
- <TagsListByLetter tags={tags} />
30
- </main>
21
+ <HtmlClassNameProvider
22
+ className={clsx(
23
+ ThemeClassNames.wrapper.docsPages,
24
+ ThemeClassNames.page.docsTagsListPage,
25
+ )}>
26
+ <PageMetadata title={title} />
27
+ <SearchMetadata tag="doc_tags_list" />
28
+ <Layout>
29
+ <div className="container margin-vert--lg">
30
+ <div className="row">
31
+ <main className="col col--8 col--offset-2">
32
+ <h1>{title}</h1>
33
+ <TagsListByLetter tags={tags} />
34
+ </main>
35
+ </div>
31
36
  </div>
32
- </div>
33
- </Layout>
37
+ </Layout>
38
+ </HtmlClassNameProvider>
34
39
  );
35
40
  }
@@ -0,0 +1,18 @@
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
+ export default function FooterCopyright({copyright}) {
9
+ return (
10
+ <div
11
+ className="footer__copyright" // Developer provided the HTML, so assume it's safe.
12
+ // eslint-disable-next-line react/no-danger
13
+ dangerouslySetInnerHTML={{
14
+ __html: copyright,
15
+ }}
16
+ />
17
+ );
18
+ }
@@ -0,0 +1,26 @@
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 clsx from 'clsx';
9
+ export default function FooterLayout({style, links, logo, copyright}) {
10
+ return (
11
+ <footer
12
+ className={clsx('footer', {
13
+ 'footer--dark': style === 'dark',
14
+ })}>
15
+ <div className="container container-fluid">
16
+ {links}
17
+ {(logo || copyright) && (
18
+ <div className="footer__bottom text--center">
19
+ {logo && <div className="margin-bottom--sm">{logo}</div>}
20
+ {copyright}
21
+ </div>
22
+ )}
23
+ </div>
24
+ </footer>
25
+ );
26
+ }
@@ -0,0 +1,33 @@
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 Link from '@docusaurus/Link';
9
+ import useBaseUrl from '@docusaurus/useBaseUrl';
10
+ import isInternalUrl from '@docusaurus/isInternalUrl';
11
+ import IconExternalLink from '@theme/IconExternalLink';
12
+ export default function FooterLinkItem({item}) {
13
+ const {to, href, label, prependBaseUrlToHref, ...props} = item;
14
+ const toUrl = useBaseUrl(to);
15
+ const normalizedHref = useBaseUrl(href, {
16
+ forcePrependBaseUrl: true,
17
+ });
18
+ return (
19
+ <Link
20
+ className="footer__link-item"
21
+ {...(href
22
+ ? {
23
+ href: prependBaseUrlToHref ? normalizedHref : href,
24
+ }
25
+ : {
26
+ to: toUrl,
27
+ })}
28
+ {...props}>
29
+ {label}
30
+ {href && !isInternalUrl(href) && <IconExternalLink />}
31
+ </Link>
32
+ );
33
+ }
@@ -0,0 +1,47 @@
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 LinkItem from '@theme/Footer/LinkItem';
9
+
10
+ function ColumnLinkItem({item}) {
11
+ return item.html ? (
12
+ <li
13
+ className="footer__item" // Developer provided the HTML, so assume it's safe.
14
+ // eslint-disable-next-line react/no-danger
15
+ dangerouslySetInnerHTML={{
16
+ __html: item.html,
17
+ }}
18
+ />
19
+ ) : (
20
+ <li key={item.href || item.to} className="footer__item">
21
+ <LinkItem item={item} />
22
+ </li>
23
+ );
24
+ }
25
+
26
+ function Column({column}) {
27
+ return (
28
+ <div className="col footer__col">
29
+ <div className="footer__title">{column.title}</div>
30
+ <ul className="footer__items">
31
+ {column.items.map((item, i) => (
32
+ <ColumnLinkItem key={i} item={item} />
33
+ ))}
34
+ </ul>
35
+ </div>
36
+ );
37
+ }
38
+
39
+ export default function FooterLinksMultiColumn({columns}) {
40
+ return (
41
+ <div className="row footer__links">
42
+ {columns.map((column, i) => (
43
+ <Column key={i} column={column} />
44
+ ))}
45
+ </div>
46
+ );
47
+ }
@@ -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
+ import React from 'react';
8
+ import LinkItem from '@theme/Footer/LinkItem';
9
+
10
+ function Separator() {
11
+ return <span className="footer__link-separator">·</span>;
12
+ }
13
+
14
+ function SimpleLinkItem({item}) {
15
+ return item.html ? (
16
+ <span
17
+ className="footer__link-item" // Developer provided the HTML, so assume it's safe.
18
+ // eslint-disable-next-line react/no-danger
19
+ dangerouslySetInnerHTML={{
20
+ __html: item.html,
21
+ }}
22
+ />
23
+ ) : (
24
+ <LinkItem item={item} />
25
+ );
26
+ }
27
+
28
+ export default function FooterLinksSimple({links}) {
29
+ return (
30
+ <div className="footer__links text--center">
31
+ <div className="footer__links">
32
+ {links.map((item, i) => (
33
+ <React.Fragment key={i}>
34
+ <SimpleLinkItem item={item} />
35
+ {links.length !== i + 1 && <Separator />}
36
+ </React.Fragment>
37
+ ))}
38
+ </div>
39
+ </div>
40
+ );
41
+ }
@@ -0,0 +1,17 @@
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 {isMultiColumnFooterLinks} from '@docusaurus/theme-common';
9
+ import FooterLinksMultiColumn from '@theme/Footer/Links/MultiColumn';
10
+ import FooterLinksSimple from '@theme/Footer/Links/Simple';
11
+ export default function FooterLinks({links}) {
12
+ return isMultiColumnFooterLinks(links) ? (
13
+ <FooterLinksMultiColumn columns={links} />
14
+ ) : (
15
+ <FooterLinksSimple links={links} />
16
+ );
17
+ }
@@ -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
+ import React from 'react';
8
+ import Link from '@docusaurus/Link';
9
+ import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
10
+ import styles from './styles.module.css';
11
+ import ThemedImage from '@theme/ThemedImage';
12
+
13
+ function LogoImage({logo}) {
14
+ const {withBaseUrl} = useBaseUrlUtils();
15
+ const sources = {
16
+ light: withBaseUrl(logo.src),
17
+ dark: withBaseUrl(logo.srcDark ?? logo.src),
18
+ };
19
+ return (
20
+ <ThemedImage
21
+ className="footer__logo"
22
+ alt={logo.alt}
23
+ sources={sources}
24
+ width={logo.width}
25
+ height={logo.height}
26
+ />
27
+ );
28
+ }
29
+
30
+ export default function FooterLogo({logo}) {
31
+ return logo.href ? (
32
+ <Link href={logo.href} className={styles.footerLogoLink}>
33
+ <LogoImage logo={logo} />
34
+ </Link>
35
+ ) : (
36
+ <LogoImage logo={logo} />
37
+ );
38
+ }
@@ -5,179 +5,27 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import clsx from 'clsx';
9
- import Link from '@docusaurus/Link';
10
8
  import {useThemeConfig} from '@docusaurus/theme-common';
11
- import useBaseUrl from '@docusaurus/useBaseUrl';
12
- import isInternalUrl from '@docusaurus/isInternalUrl';
13
- import styles from './styles.module.css';
14
- import ThemedImage from '@theme/ThemedImage';
15
- import IconExternalLink from '@theme/IconExternalLink';
16
-
17
- function FooterLink({to, href, label, prependBaseUrlToHref, ...props}) {
18
- const toUrl = useBaseUrl(to);
19
- const normalizedHref = useBaseUrl(href, {
20
- forcePrependBaseUrl: true,
21
- });
22
- return (
23
- <Link
24
- className="footer__link-item"
25
- {...(href
26
- ? {
27
- href: prependBaseUrlToHref ? normalizedHref : href,
28
- }
29
- : {
30
- to: toUrl,
31
- })}
32
- {...props}>
33
- {href && !isInternalUrl(href) ? (
34
- <span>
35
- {label}
36
- <IconExternalLink />
37
- </span>
38
- ) : (
39
- label
40
- )}
41
- </Link>
42
- );
43
- }
44
-
45
- function FooterLogo({sources, alt, width, height}) {
46
- return (
47
- <ThemedImage
48
- className="footer__logo"
49
- alt={alt}
50
- sources={sources}
51
- width={width}
52
- height={height}
53
- />
54
- );
55
- }
56
-
57
- function MultiColumnLinks({links}) {
58
- return (
59
- <>
60
- {links.map((linkItem, i) => (
61
- <div key={i} className="col footer__col">
62
- <div className="footer__title">{linkItem.title}</div>
63
- <ul className="footer__items">
64
- {linkItem.items.map((item, key) =>
65
- item.html ? (
66
- <li
67
- key={key}
68
- className="footer__item" // Developer provided the HTML, so assume it's safe.
69
- // eslint-disable-next-line react/no-danger
70
- dangerouslySetInnerHTML={{
71
- __html: item.html,
72
- }}
73
- />
74
- ) : (
75
- <li key={item.href || item.to} className="footer__item">
76
- <FooterLink {...item} />
77
- </li>
78
- ),
79
- )}
80
- </ul>
81
- </div>
82
- ))}
83
- </>
84
- );
85
- }
86
-
87
- function SimpleLinks({links}) {
88
- return (
89
- <div className="footer__links">
90
- {links.map((item, key) => (
91
- <React.Fragment key={key}>
92
- {item.html ? (
93
- <span
94
- className="footer__link-item" // Developer provided the HTML, so assume it's safe.
95
- // eslint-disable-next-line react/no-danger
96
- dangerouslySetInnerHTML={{
97
- __html: item.html,
98
- }}
99
- />
100
- ) : (
101
- <FooterLink {...item} />
102
- )}
103
- {links.length !== key + 1 && (
104
- <span className="footer__link-separator">·</span>
105
- )}
106
- </React.Fragment>
107
- ))}
108
- </div>
109
- );
110
- }
111
-
112
- function isMultiColumnFooterLinks(links) {
113
- return 'title' in links[0];
114
- }
9
+ import FooterLinks from '@theme/Footer/Links';
10
+ import FooterLogo from '@theme/Footer/Logo';
11
+ import FooterCopyright from '@theme/Footer/Copyright';
12
+ import FooterLayout from '@theme/Footer/Layout';
115
13
 
116
14
  function Footer() {
117
15
  const {footer} = useThemeConfig();
118
- const {copyright, links = [], logo = {}} = footer || {};
119
- const sources = {
120
- light: useBaseUrl(logo.src),
121
- dark: useBaseUrl(logo.srcDark || logo.src),
122
- };
123
16
 
124
17
  if (!footer) {
125
18
  return null;
126
19
  }
127
20
 
21
+ const {copyright, links, logo, style} = footer;
128
22
  return (
129
- <footer
130
- className={clsx('footer', {
131
- 'footer--dark': footer.style === 'dark',
132
- })}>
133
- <div className="container container-fluid">
134
- {links &&
135
- links.length > 0 &&
136
- (isMultiColumnFooterLinks(links) ? (
137
- <div className="row footer__links">
138
- <MultiColumnLinks links={links} />
139
- </div>
140
- ) : (
141
- <div className="footer__links text--center">
142
- <SimpleLinks links={links} />
143
- </div>
144
- ))}
145
- {(logo || copyright) && (
146
- <div className="footer__bottom text--center">
147
- {logo && (logo.src || logo.srcDark) && (
148
- <div className="margin-bottom--sm">
149
- {logo.href ? (
150
- <Link href={logo.href} className={styles.footerLogoLink}>
151
- <FooterLogo
152
- alt={logo.alt}
153
- sources={sources}
154
- width={logo.width}
155
- height={logo.height}
156
- />
157
- </Link>
158
- ) : (
159
- <FooterLogo
160
- alt={logo.alt}
161
- sources={sources}
162
- width={logo.width}
163
- height={logo.height}
164
- />
165
- )}
166
- </div>
167
- )}
168
- {copyright ? (
169
- <div
170
- className="footer__copyright" // Developer provided the HTML, so assume it's safe.
171
- // eslint-disable-next-line react/no-danger
172
- dangerouslySetInnerHTML={{
173
- __html: copyright,
174
- }}
175
- />
176
- ) : null}
177
- </div>
178
- )}
179
- </div>
180
- </footer>
23
+ <FooterLayout
24
+ style={style}
25
+ links={links && links.length > 0 && <FooterLinks links={links} />}
26
+ logo={logo && <FooterLogo logo={logo} />}
27
+ copyright={copyright && <FooterCopyright copyright={copyright} />}
28
+ />
181
29
  );
182
30
  }
183
31
 
@@ -22,10 +22,12 @@ function AnchorHeading({as: As, id, ...props}) {
22
22
  return (
23
23
  <As
24
24
  {...props}
25
- className={clsx('anchor', {
26
- [styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
27
- [styles.anchorWithStickyNavbar]: !hideOnScroll,
28
- })}
25
+ className={clsx(
26
+ 'anchor',
27
+ hideOnScroll
28
+ ? styles.anchorWithHideOnScrollNavbar
29
+ : styles.anchorWithStickyNavbar,
30
+ )}
29
31
  id={id}>
30
32
  {props.children}
31
33
  <a
@@ -7,6 +7,4 @@
7
7
 
8
8
  .iconExternalLink {
9
9
  margin-left: 0.3rem;
10
- position: relative;
11
- top: 1px;
12
10
  }