@docusaurus/theme-classic 0.0.0-4279 → 0.0.0-4286

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 (154) hide show
  1. package/lib/theme-classic.d.ts +9 -14
  2. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +1 -2
  3. package/lib-next/theme/Tabs/index.js +14 -7
  4. package/package.json +12 -12
  5. package/src/index.ts +2 -5
  6. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +1 -2
  7. package/src/theme/Tabs/index.tsx +18 -6
  8. package/src/theme-classic.d.ts +9 -14
  9. package/babel.config.js +0 -35
  10. package/lib/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  11. package/lib/__tests__/translations.test.js +0 -112
  12. package/lib/__tests__/validateThemeConfig.test.js +0 -607
  13. package/lib/theme/AnnouncementBar/index.js +0 -68
  14. package/lib/theme/AnnouncementBar/styles.module.css +0 -63
  15. package/lib/theme/BackToTopButton/index.js +0 -140
  16. package/lib/theme/BackToTopButton/styles.module.css +0 -42
  17. package/lib/theme/BlogArchivePage/index.js +0 -89
  18. package/lib/theme/BlogLayout/index.js +0 -51
  19. package/lib/theme/BlogListPage/index.js +0 -60
  20. package/lib/theme/BlogListPaginator/index.js +0 -63
  21. package/lib/theme/BlogPostAuthor/index.js +0 -51
  22. package/lib/theme/BlogPostAuthor/styles.module.css +0 -12
  23. package/lib/theme/BlogPostAuthors/index.js +0 -47
  24. package/lib/theme/BlogPostAuthors/styles.module.css +0 -11
  25. package/lib/theme/BlogPostItem/index.js +0 -152
  26. package/lib/theme/BlogPostItem/styles.module.css +0 -18
  27. package/lib/theme/BlogPostPage/index.js +0 -82
  28. package/lib/theme/BlogPostPaginator/index.js +0 -64
  29. package/lib/theme/BlogSidebar/index.js +0 -49
  30. package/lib/theme/BlogSidebar/styles.module.css +0 -44
  31. package/lib/theme/BlogTagsListPage/index.js +0 -40
  32. package/lib/theme/BlogTagsPostsPage/index.js +0 -86
  33. package/lib/theme/CodeBlock/index.js +0 -133
  34. package/lib/theme/CodeBlock/styles.module.css +0 -65
  35. package/lib/theme/Details/index.js +0 -30
  36. package/lib/theme/Details/styles.module.css +0 -13
  37. package/lib/theme/DocCard/index.js +0 -84
  38. package/lib/theme/DocCard/styles.module.css +0 -43
  39. package/lib/theme/DocCardList/index.js +0 -28
  40. package/lib/theme/DocCategoryGeneratedIndexPage/index.js +0 -57
  41. package/lib/theme/DocCategoryGeneratedIndexPage/styles.module.css +0 -18
  42. package/lib/theme/DocItem/index.js +0 -112
  43. package/lib/theme/DocItem/styles.module.css +0 -22
  44. package/lib/theme/DocItemFooter/index.js +0 -79
  45. package/lib/theme/DocItemFooter/styles.module.css +0 -18
  46. package/lib/theme/DocPage/index.js +0 -154
  47. package/lib/theme/DocPage/styles.module.css +0 -85
  48. package/lib/theme/DocPaginator/index.js +0 -62
  49. package/lib/theme/DocSidebar/index.js +0 -134
  50. package/lib/theme/DocSidebar/styles.module.css +0 -106
  51. package/lib/theme/DocSidebarItem/index.js +0 -209
  52. package/lib/theme/DocSidebarItem/styles.module.css +0 -19
  53. package/lib/theme/DocTagDocListPage/index.js +0 -89
  54. package/lib/theme/DocTagsListPage/index.js +0 -44
  55. package/lib/theme/DocVersionBadge/index.js +0 -34
  56. package/lib/theme/DocVersionBanner/index.js +0 -130
  57. package/lib/theme/EditThisPage/index.js +0 -33
  58. package/lib/theme/ErrorPageContent.js +0 -43
  59. package/lib/theme/Footer/index.js +0 -119
  60. package/lib/theme/Footer/styles.module.css +0 -15
  61. package/lib/theme/Heading/index.js +0 -71
  62. package/lib/theme/Heading/styles.css +0 -22
  63. package/lib/theme/Heading/styles.module.css +0 -19
  64. package/lib/theme/IconArrow/index.js +0 -28
  65. package/lib/theme/IconClose/index.js +0 -31
  66. package/lib/theme/IconEdit/index.js +0 -34
  67. package/lib/theme/IconEdit/styles.module.css +0 -11
  68. package/lib/theme/IconExternalLink/index.js +0 -30
  69. package/lib/theme/IconExternalLink/styles.module.css +0 -12
  70. package/lib/theme/IconLanguage/index.js +0 -29
  71. package/lib/theme/IconMenu/index.js +0 -30
  72. package/lib/theme/LastUpdated/index.js +0 -63
  73. package/lib/theme/Layout/index.js +0 -68
  74. package/lib/theme/Layout/styles.css +0 -27
  75. package/lib/theme/LayoutHead/index.js +0 -149
  76. package/lib/theme/LayoutProviders/index.js +0 -40
  77. package/lib/theme/Logo/index.js +0 -62
  78. package/lib/theme/MDXComponents/index.js +0 -106
  79. package/lib/theme/MDXComponents/styles.css +0 -11
  80. package/lib/theme/MDXPage/index.js +0 -67
  81. package/lib/theme/MDXPage/styles.module.css +0 -10
  82. package/lib/theme/Navbar/index.js +0 -267
  83. package/lib/theme/Navbar/styles.module.css +0 -27
  84. package/lib/theme/NavbarItem/DefaultNavbarItem.js +0 -113
  85. package/lib/theme/NavbarItem/DocNavbarItem.js +0 -62
  86. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -83
  87. package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +0 -43
  88. package/lib/theme/NavbarItem/DropdownNavbarItem.js +0 -155
  89. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +0 -68
  90. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +0 -11
  91. package/lib/theme/NavbarItem/SearchNavbarItem.js +0 -28
  92. package/lib/theme/NavbarItem/index.js +0 -74
  93. package/lib/theme/NotFound.js +0 -57
  94. package/lib/theme/SearchBar.js +0 -15
  95. package/lib/theme/SearchMetadata/index.js +0 -33
  96. package/lib/theme/Seo/index.js +0 -52
  97. package/lib/theme/SkipToContent/index.js +0 -71
  98. package/lib/theme/SkipToContent/styles.module.css +0 -14
  99. package/lib/theme/TOC/index.js +0 -39
  100. package/lib/theme/TOC/styles.module.css +0 -23
  101. package/lib/theme/TOCCollapsible/index.js +0 -53
  102. package/lib/theme/TOCCollapsible/styles.module.css +0 -50
  103. package/lib/theme/TOCInline/index.js +0 -33
  104. package/lib/theme/TOCInline/styles.module.css +0 -12
  105. package/lib/theme/TOCItems/index.js +0 -78
  106. package/lib/theme/TabItem/index.js +0 -32
  107. package/lib/theme/Tabs/__tests__/index.test.js +0 -123
  108. package/lib/theme/Tabs/index.js +0 -173
  109. package/lib/theme/Tabs/styles.module.css +0 -10
  110. package/lib/theme/Tag/index.js +0 -40
  111. package/lib/theme/Tag/styles.module.css +0 -70
  112. package/lib/theme/TagsListByLetter/index.js +0 -48
  113. package/lib/theme/TagsListByLetter/styles.module.css +0 -11
  114. package/lib/theme/TagsListInline/index.js +0 -44
  115. package/lib/theme/TagsListInline/styles.module.css +0 -15
  116. package/lib/theme/ThemeContext.js +0 -21
  117. package/lib/theme/ThemeProvider/index.js +0 -43
  118. package/lib/theme/ThemedImage/index.js +0 -47
  119. package/lib/theme/ThemedImage/styles.module.css +0 -18
  120. package/lib/theme/Toggle/index.js +0 -91
  121. package/lib/theme/Toggle/styles.module.css +0 -105
  122. package/lib/theme/UserPreferencesContext.js +0 -18
  123. package/lib/theme/UserPreferencesProvider/index.js +0 -41
  124. package/lib/theme/hooks/styles.css +0 -10
  125. package/lib/theme/hooks/useDocs.js +0 -18
  126. package/lib/theme/hooks/useHideableNavbar.js +0 -74
  127. package/lib/theme/hooks/useKeyboardNavigation.js +0 -45
  128. package/lib/theme/hooks/useLocationHash.js +0 -28
  129. package/lib/theme/hooks/useLockBodyScroll.js +0 -26
  130. package/lib/theme/hooks/usePrismTheme.js +0 -36
  131. package/lib/theme/hooks/useTabGroupChoice.js +0 -51
  132. package/lib/theme/hooks/useTheme.js +0 -97
  133. package/lib/theme/hooks/useThemeContext.js +0 -31
  134. package/lib/theme/hooks/useUserPreferencesContext.js +0 -31
  135. package/lib/theme/hooks/useWindowSize.js +0 -68
  136. package/lib/theme/prism-include-languages.js +0 -40
  137. package/lib-next/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  138. package/lib-next/__tests__/translations.test.js +0 -128
  139. package/lib-next/__tests__/validateThemeConfig.test.js +0 -607
  140. package/lib-next/admonitions.css +0 -35
  141. package/lib-next/deps.d.ts +0 -13
  142. package/lib-next/index.js +0 -227
  143. package/lib-next/prism-include-languages.js +0 -9
  144. package/lib-next/theme/hooks/useLocationHash.js +0 -20
  145. package/lib-next/theme-classic.d.ts +0 -806
  146. package/lib-next/translations.js +0 -141
  147. package/lib-next/types.d.ts +0 -11
  148. package/lib-next/validateThemeConfig.js +0 -344
  149. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  150. package/src/__tests__/translations.test.ts +0 -116
  151. package/src/__tests__/validateThemeConfig.test.js +0 -607
  152. package/src/theme/Tabs/__tests__/index.test.tsx +0 -129
  153. package/src/theme/hooks/useLocationHash.ts +0 -25
  154. package/tsconfig.json +0 -11
@@ -6,7 +6,9 @@
6
6
  */
7
7
 
8
8
  declare module '@docusaurus/theme-classic' {
9
- export type Options = Partial<import('./index').PluginOptions>;
9
+ export type Options = {
10
+ customCss?: string | string[];
11
+ };
10
12
  }
11
13
 
12
14
  declare module '@theme/AnnouncementBar' {
@@ -202,18 +204,6 @@ declare module '@theme/hooks/useHideableNavbar' {
202
204
  export default useHideableNavbar;
203
205
  }
204
206
 
205
- declare module '@theme/hooks/useLocationHash' {
206
- import type {Dispatch, SetStateAction} from 'react';
207
-
208
- export type useLocationHashReturns = readonly [
209
- string,
210
- Dispatch<SetStateAction<string>>,
211
- ];
212
-
213
- const useLocationHash: (initialHash: string) => useLocationHashReturns;
214
- export default useLocationHash;
215
- }
216
-
217
207
  declare module '@theme/hooks/useLockBodyScroll' {
218
208
  const useLockBodyScroll: (lock?: boolean) => void;
219
209
  export default useLockBodyScroll;
@@ -526,6 +516,7 @@ declare module '@theme/TabItem' {
526
516
  readonly label?: string;
527
517
  readonly hidden?: boolean;
528
518
  readonly className?: string;
519
+ readonly attributes?: Record<string, unknown>;
529
520
  }
530
521
 
531
522
  const TabItem: (props: Props) => JSX.Element;
@@ -541,7 +532,11 @@ declare module '@theme/Tabs' {
541
532
  readonly block?: boolean;
542
533
  readonly children: readonly ReactElement<TabItemProps>[];
543
534
  readonly defaultValue?: string | null;
544
- readonly values?: readonly {value: string; label?: string}[];
535
+ readonly values?: readonly {
536
+ value: string;
537
+ label?: string;
538
+ attributes?: Record<string, unknown>;
539
+ }[];
545
540
  readonly groupId?: string;
546
541
  readonly className?: string;
547
542
  }
@@ -39,7 +39,6 @@ function containsActiveItems(items, localPathname) {
39
39
 
40
40
  function DropdownNavbarItemDesktop({items, position, className, ...props}) {
41
41
  const dropdownRef = useRef(null);
42
- const dropdownMenuRef = useRef(null);
43
42
  const [showDropdown, setShowDropdown] = useState(false);
44
43
  useEffect(() => {
45
44
  const handleClickOutside = (event) => {
@@ -77,7 +76,7 @@ function DropdownNavbarItemDesktop({items, position, className, ...props}) {
77
76
  }}>
78
77
  {props.children ?? props.label}
79
78
  </NavLink>
80
- <ul ref={dropdownMenuRef} className="dropdown__menu">
79
+ <ul className="dropdown__menu">
81
80
  {items.map((childItemProps, i) => (
82
81
  <NavbarItem
83
82
  isDropdownItem
@@ -39,10 +39,11 @@ function TabsComponent(props) {
39
39
  );
40
40
  });
41
41
  const values =
42
- valuesProp ??
43
- children.map(({props: {value, label}}) => ({
42
+ valuesProp ?? // We only pick keys that we recognize. MDX would inject some keys by default
43
+ children.map(({props: {value, label, attributes}}) => ({
44
44
  value,
45
45
  label,
46
+ attributes,
46
47
  }));
47
48
  const dup = duplicates(values, (a, b) => a.value === b.value);
48
49
 
@@ -139,19 +140,25 @@ function TabsComponent(props) {
139
140
  },
140
141
  className,
141
142
  )}>
142
- {values.map(({value, label}) => (
143
+ {values.map(({value, label, attributes}) => (
143
144
  <li
144
145
  role="tab"
145
146
  tabIndex={selectedValue === value ? 0 : -1}
146
147
  aria-selected={selectedValue === value}
147
- className={clsx('tabs__item', styles.tabItem, {
148
- 'tabs__item--active': selectedValue === value,
149
- })}
150
148
  key={value}
151
149
  ref={(tabControl) => tabRefs.push(tabControl)}
152
150
  onKeyDown={handleKeydown}
153
151
  onFocus={handleTabChange}
154
- onClick={handleTabChange}>
152
+ onClick={handleTabChange}
153
+ {...attributes}
154
+ className={clsx(
155
+ 'tabs__item',
156
+ styles.tabItem,
157
+ attributes?.className,
158
+ {
159
+ 'tabs__item--active': selectedValue === value,
160
+ },
161
+ )}>
155
162
  {label ?? value}
156
163
  </li>
157
164
  ))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4279",
3
+ "version": "0.0.0-4286",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -23,14 +23,14 @@
23
23
  "update-code-translations": "node -e 'require(\"./update-code-translations.js\").run()'"
24
24
  },
25
25
  "dependencies": {
26
- "@docusaurus/core": "0.0.0-4279",
27
- "@docusaurus/plugin-content-blog": "0.0.0-4279",
28
- "@docusaurus/plugin-content-docs": "0.0.0-4279",
29
- "@docusaurus/plugin-content-pages": "0.0.0-4279",
30
- "@docusaurus/theme-common": "0.0.0-4279",
31
- "@docusaurus/theme-translations": "0.0.0-4279",
32
- "@docusaurus/utils": "0.0.0-4279",
33
- "@docusaurus/utils-validation": "0.0.0-4279",
26
+ "@docusaurus/core": "0.0.0-4286",
27
+ "@docusaurus/plugin-content-blog": "0.0.0-4286",
28
+ "@docusaurus/plugin-content-docs": "0.0.0-4286",
29
+ "@docusaurus/plugin-content-pages": "0.0.0-4286",
30
+ "@docusaurus/theme-common": "0.0.0-4286",
31
+ "@docusaurus/theme-translations": "0.0.0-4286",
32
+ "@docusaurus/utils": "0.0.0-4286",
33
+ "@docusaurus/utils-validation": "0.0.0-4286",
34
34
  "@mdx-js/mdx": "^1.6.21",
35
35
  "@mdx-js/react": "^1.6.21",
36
36
  "chalk": "^4.1.2",
@@ -46,8 +46,8 @@
46
46
  "rtlcss": "^3.3.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@docusaurus/module-type-aliases": "0.0.0-4279",
50
- "@docusaurus/types": "0.0.0-4279",
49
+ "@docusaurus/module-type-aliases": "0.0.0-4286",
50
+ "@docusaurus/types": "0.0.0-4286",
51
51
  "@types/mdx-js__react": "^1.5.4",
52
52
  "@types/parse-numeric-range": "^0.0.1",
53
53
  "@types/rtlcss": "^3.1.1",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=14"
64
64
  },
65
- "gitHead": "6075dccc83c1127e43a59b5f881bf8da07390962"
65
+ "gitHead": "2a87bcff19729fff3df8fe20ca79fcac87b31371"
66
66
  }
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ import {createRequire} from 'module';
13
13
  import type {Plugin as PostCssPlugin} from 'postcss';
14
14
  import rtlcss from 'rtlcss';
15
15
  import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
16
+ import type {Options} from '@docusaurus/theme-classic';
16
17
 
17
18
  const requireFromDocusaurusCore = createRequire(
18
19
  require.resolve('@docusaurus/core/package.json'),
@@ -89,13 +90,9 @@ function getInfimaCSSFile(direction: string) {
89
90
  }.css`;
90
91
  }
91
92
 
92
- export type PluginOptions = {
93
- customCss?: string | string[];
94
- };
95
-
96
93
  export default function docusaurusThemeClassic(
97
94
  context: DocusaurusContext, // TODO: LoadContext is missing some of properties
98
- options: PluginOptions,
95
+ options: Options,
99
96
  ): Plugin<void> {
100
97
  const {
101
98
  siteConfig: {themeConfig: roughlyTypedThemeConfig},
@@ -55,7 +55,6 @@ function DropdownNavbarItemDesktop({
55
55
  ...props
56
56
  }: DesktopOrMobileNavBarItemProps) {
57
57
  const dropdownRef = useRef<HTMLDivElement>(null);
58
- const dropdownMenuRef = useRef<HTMLUListElement>(null);
59
58
  const [showDropdown, setShowDropdown] = useState(false);
60
59
 
61
60
  useEffect(() => {
@@ -98,7 +97,7 @@ function DropdownNavbarItemDesktop({
98
97
  }}>
99
98
  {props.children ?? props.label}
100
99
  </NavLink>
101
- <ul ref={dropdownMenuRef} className="dropdown__menu">
100
+ <ul className="dropdown__menu">
102
101
  {items.map((childItemProps, i) => (
103
102
  <NavbarItem
104
103
  isDropdownItem
@@ -51,7 +51,13 @@ function TabsComponent(props: Props): JSX.Element {
51
51
  );
52
52
  });
53
53
  const values =
54
- valuesProp ?? children.map(({props: {value, label}}) => ({value, label}));
54
+ valuesProp ??
55
+ // We only pick keys that we recognize. MDX would inject some keys by default
56
+ children.map(({props: {value, label, attributes}}) => ({
57
+ value,
58
+ label,
59
+ attributes,
60
+ }));
55
61
  const dup = duplicates(values, (a, b) => a.value === b.value);
56
62
  if (dup.length > 0) {
57
63
  throw new Error(
@@ -144,19 +150,25 @@ function TabsComponent(props: Props): JSX.Element {
144
150
  },
145
151
  className,
146
152
  )}>
147
- {values.map(({value, label}) => (
153
+ {values.map(({value, label, attributes}) => (
148
154
  <li
149
155
  role="tab"
150
156
  tabIndex={selectedValue === value ? 0 : -1}
151
157
  aria-selected={selectedValue === value}
152
- className={clsx('tabs__item', styles.tabItem, {
153
- 'tabs__item--active': selectedValue === value,
154
- })}
155
158
  key={value}
156
159
  ref={(tabControl) => tabRefs.push(tabControl)}
157
160
  onKeyDown={handleKeydown}
158
161
  onFocus={handleTabChange}
159
- onClick={handleTabChange}>
162
+ onClick={handleTabChange}
163
+ {...attributes}
164
+ className={clsx(
165
+ 'tabs__item',
166
+ styles.tabItem,
167
+ attributes?.className as string,
168
+ {
169
+ 'tabs__item--active': selectedValue === value,
170
+ },
171
+ )}>
160
172
  {label ?? value}
161
173
  </li>
162
174
  ))}
@@ -6,7 +6,9 @@
6
6
  */
7
7
 
8
8
  declare module '@docusaurus/theme-classic' {
9
- export type Options = Partial<import('./index').PluginOptions>;
9
+ export type Options = {
10
+ customCss?: string | string[];
11
+ };
10
12
  }
11
13
 
12
14
  declare module '@theme/AnnouncementBar' {
@@ -202,18 +204,6 @@ declare module '@theme/hooks/useHideableNavbar' {
202
204
  export default useHideableNavbar;
203
205
  }
204
206
 
205
- declare module '@theme/hooks/useLocationHash' {
206
- import type {Dispatch, SetStateAction} from 'react';
207
-
208
- export type useLocationHashReturns = readonly [
209
- string,
210
- Dispatch<SetStateAction<string>>,
211
- ];
212
-
213
- const useLocationHash: (initialHash: string) => useLocationHashReturns;
214
- export default useLocationHash;
215
- }
216
-
217
207
  declare module '@theme/hooks/useLockBodyScroll' {
218
208
  const useLockBodyScroll: (lock?: boolean) => void;
219
209
  export default useLockBodyScroll;
@@ -526,6 +516,7 @@ declare module '@theme/TabItem' {
526
516
  readonly label?: string;
527
517
  readonly hidden?: boolean;
528
518
  readonly className?: string;
519
+ readonly attributes?: Record<string, unknown>;
529
520
  }
530
521
 
531
522
  const TabItem: (props: Props) => JSX.Element;
@@ -541,7 +532,11 @@ declare module '@theme/Tabs' {
541
532
  readonly block?: boolean;
542
533
  readonly children: readonly ReactElement<TabItemProps>[];
543
534
  readonly defaultValue?: string | null;
544
- readonly values?: readonly {value: string; label?: string}[];
535
+ readonly values?: readonly {
536
+ value: string;
537
+ label?: string;
538
+ attributes?: Record<string, unknown>;
539
+ }[];
545
540
  readonly groupId?: string;
546
541
  readonly className?: string;
547
542
  }
package/babel.config.js DELETED
@@ -1,35 +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
- module.exports = {
9
- env: {
10
- // USED FOR NODE/RUNTIME
11
- // maybe we should differenciate both cases because
12
- // we mostly need to transpile some features so that node does not crash...
13
- lib: {
14
- presets: [
15
- ['@babel/preset-typescript', {isTSX: true, allExtensions: true}],
16
- ],
17
- // Useful to transpile for older node versions
18
- plugins: [
19
- '@babel/plugin-transform-modules-commonjs',
20
- '@babel/plugin-proposal-nullish-coalescing-operator',
21
- '@babel/plugin-proposal-optional-chaining',
22
- ],
23
- },
24
-
25
- // USED FOR JS SWIZZLE
26
- // /lib-next folder is used as source to swizzle JS source code
27
- // This JS code is created from TS source code
28
- // This source code should look clean/human readable to be usable
29
- 'lib-next': {
30
- presets: [
31
- ['@babel/preset-typescript', {isTSX: true, allExtensions: true}],
32
- ],
33
- },
34
- },
35
- };
@@ -1,116 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`getTranslationFiles should return translation files matching snapshot 1`] = `
4
- Array [
5
- Object {
6
- "content": Object {
7
- "item.label.Dropdown": Object {
8
- "description": "Navbar item with label Dropdown",
9
- "message": "Dropdown",
10
- },
11
- "item.label.Dropdown item 1": Object {
12
- "description": "Navbar item with label Dropdown item 1",
13
- "message": "Dropdown item 1",
14
- },
15
- "item.label.Dropdown item 2": Object {
16
- "description": "Navbar item with label Dropdown item 2",
17
- "message": "Dropdown item 2",
18
- },
19
- "title": Object {
20
- "description": "The title in the navbar",
21
- "message": "navbar title",
22
- },
23
- },
24
- "path": "navbar",
25
- },
26
- Object {
27
- "content": Object {
28
- "copyright": Object {
29
- "description": "The footer copyright",
30
- "message": "Copyright FB",
31
- },
32
- "link.item.label.Link 1": Object {
33
- "description": "The label of footer link with label=Link 1 linking to https://facebook.com",
34
- "message": "Link 1",
35
- },
36
- "link.item.label.Link 2": Object {
37
- "description": "The label of footer link with label=Link 2 linking to https://facebook.com",
38
- "message": "Link 2",
39
- },
40
- "link.item.label.Link 3": Object {
41
- "description": "The label of footer link with label=Link 3 linking to https://facebook.com",
42
- "message": "Link 3",
43
- },
44
- "link.title.Footer link column 1": Object {
45
- "description": "The title of the footer links column with title=Footer link column 1 in the footer",
46
- "message": "Footer link column 1",
47
- },
48
- "link.title.Footer link column 2": Object {
49
- "description": "The title of the footer links column with title=Footer link column 2 in the footer",
50
- "message": "Footer link column 2",
51
- },
52
- },
53
- "path": "footer",
54
- },
55
- ]
56
- `;
57
-
58
- exports[`translateThemeConfig should return translated themeConfig matching snapshot 1`] = `
59
- Object {
60
- "announcementBar": Object {},
61
- "colorMode": Object {},
62
- "docs": Object {
63
- "versionPersistence": "none",
64
- },
65
- "footer": Object {
66
- "copyright": "Copyright FB (translated)",
67
- "links": Array [
68
- Object {
69
- "items": Array [
70
- Object {
71
- "label": "Link 1 (translated)",
72
- "to": "https://facebook.com",
73
- },
74
- Object {
75
- "label": "Link 2 (translated)",
76
- "to": "https://facebook.com",
77
- },
78
- ],
79
- "title": "Footer link column 1 (translated)",
80
- },
81
- Object {
82
- "items": Array [
83
- Object {
84
- "label": "Link 3 (translated)",
85
- "to": "https://facebook.com",
86
- },
87
- ],
88
- "title": "Footer link column 2 (translated)",
89
- },
90
- ],
91
- "style": "light",
92
- },
93
- "hideableSidebar": true,
94
- "navbar": Object {
95
- "hideOnScroll": false,
96
- "items": Array [
97
- Object {
98
- "items": Array [
99
- Object {
100
- "items": Array [],
101
- "label": "Dropdown item 1 (translated)",
102
- },
103
- Object {
104
- "items": Array [],
105
- "label": "Dropdown item 2 (translated)",
106
- },
107
- ],
108
- "label": "Dropdown (translated)",
109
- },
110
- ],
111
- "style": "dark",
112
- "title": "navbar title (translated)",
113
- },
114
- "prism": Object {},
115
- }
116
- `;
@@ -1,112 +0,0 @@
1
- "use strict";
2
-
3
- var _translations = require("../translations");
4
-
5
- var _utils = require("@docusaurus/utils");
6
-
7
- /**
8
- * Copyright (c) Facebook, Inc. and its affiliates.
9
- *
10
- * This source code is licensed under the MIT license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- */
13
- const ThemeConfigSample = {
14
- colorMode: {},
15
- announcementBar: {},
16
- prism: {},
17
- docs: {
18
- versionPersistence: 'none'
19
- },
20
- hideableSidebar: true,
21
- navbar: {
22
- title: 'navbar title',
23
- style: 'dark',
24
- hideOnScroll: false,
25
- items: [{
26
- label: 'Dropdown',
27
- items: [{
28
- label: 'Dropdown item 1',
29
- items: []
30
- }, {
31
- label: 'Dropdown item 2',
32
- items: []
33
- }]
34
- }]
35
- },
36
- footer: {
37
- copyright: 'Copyright FB',
38
- style: 'light',
39
- links: [{
40
- title: 'Footer link column 1',
41
- items: [{
42
- label: 'Link 1',
43
- to: 'https://facebook.com'
44
- }, {
45
- label: 'Link 2',
46
- to: 'https://facebook.com'
47
- }]
48
- }, {
49
- title: 'Footer link column 2',
50
- items: [{
51
- label: 'Link 3',
52
- to: 'https://facebook.com'
53
- }]
54
- }]
55
- }
56
- };
57
-
58
- function getSampleTranslationFiles() {
59
- return (0, _translations.getTranslationFiles)({
60
- themeConfig: ThemeConfigSample
61
- });
62
- }
63
-
64
- function getSampleTranslationFilesTranslated() {
65
- const translationFiles = getSampleTranslationFiles();
66
- return translationFiles.map(translationFile => (0, _utils.updateTranslationFileMessages)(translationFile, message => `${message} (translated)`));
67
- }
68
-
69
- describe('getTranslationFiles', () => {
70
- test('should return translation files matching snapshot', () => {
71
- expect(getSampleTranslationFiles()).toMatchSnapshot();
72
- });
73
- });
74
- describe('translateThemeConfig', () => {
75
- test('should not translate anything if translation files are untranslated', () => {
76
- const translationFiles = getSampleTranslationFiles();
77
- expect((0, _translations.translateThemeConfig)({
78
- themeConfig: ThemeConfigSample,
79
- translationFiles
80
- })).toEqual(ThemeConfigSample);
81
- });
82
- test('should return translated themeConfig matching snapshot', () => {
83
- const translationFiles = getSampleTranslationFilesTranslated();
84
- expect((0, _translations.translateThemeConfig)({
85
- themeConfig: ThemeConfigSample,
86
- translationFiles
87
- })).toMatchSnapshot();
88
- });
89
- });
90
- describe('getTranslationFiles and translateThemeConfig isomorphism', () => {
91
- function verifyIsomorphism(themeConfig) {
92
- const translationFiles = (0, _translations.getTranslationFiles)({
93
- themeConfig
94
- });
95
- const translatedThemeConfig = (0, _translations.translateThemeConfig)({
96
- themeConfig,
97
- translationFiles
98
- });
99
- expect(translatedThemeConfig).toEqual(themeConfig);
100
- }
101
-
102
- test('should be verified for main sample', () => {
103
- verifyIsomorphism(ThemeConfigSample);
104
- }); // undefined footer should not make the translation code crash
105
- // See https://github.com/facebook/docusaurus/issues/3936
106
-
107
- test('should be verified for sample without footer', () => {
108
- verifyIsomorphism({ ...ThemeConfigSample,
109
- footer: undefined
110
- });
111
- });
112
- });