@docusaurus/theme-classic 0.0.0-4554 → 0.0.0-4559

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.
@@ -20,9 +20,7 @@ function getNavbarTranslationFile(navbar) {
20
20
  // TODO handle properly all the navbar item types here!
21
21
  function flattenNavbarItems(items) {
22
22
  const subItems = items.flatMap(item => {
23
- var _item$items;
24
-
25
- const allSubItems = [(_item$items = item.items) !== null && _item$items !== void 0 ? _item$items : []].flat();
23
+ const allSubItems = [item.items ?? []].flat();
26
24
  return flattenNavbarItems(allSubItems);
27
25
  });
28
26
  return [...items, ...subItems];
@@ -43,23 +41,23 @@ function getNavbarTranslationFile(navbar) {
43
41
  }
44
42
 
45
43
  function translateNavbar(navbar, navbarTranslations) {
46
- var _navbarTranslations$t, _navbarTranslations$t2;
44
+ var _navbarTranslations$t;
47
45
 
48
46
  return { ...navbar,
49
- title: (_navbarTranslations$t = (_navbarTranslations$t2 = navbarTranslations.title) === null || _navbarTranslations$t2 === void 0 ? void 0 : _navbarTranslations$t2.message) !== null && _navbarTranslations$t !== void 0 ? _navbarTranslations$t : navbar.title,
47
+ title: ((_navbarTranslations$t = navbarTranslations.title) === null || _navbarTranslations$t === void 0 ? void 0 : _navbarTranslations$t.message) ?? navbar.title,
50
48
  // TODO handle properly all the navbar item types here!
51
49
  items: navbar.items.map(item => {
52
- var _item$items2, _navbarTranslations$$2, _navbarTranslations$2;
50
+ var _item$items, _navbarTranslations$2;
53
51
 
54
- const subItems = (_item$items2 = item.items) === null || _item$items2 === void 0 ? void 0 : _item$items2.map(subItem => {
55
- var _navbarTranslations$$, _navbarTranslations$;
52
+ const subItems = (_item$items = item.items) === null || _item$items === void 0 ? void 0 : _item$items.map(subItem => {
53
+ var _navbarTranslations$;
56
54
 
57
55
  return { ...subItem,
58
- label: (_navbarTranslations$$ = (_navbarTranslations$ = navbarTranslations[`item.label.${subItem.label}`]) === null || _navbarTranslations$ === void 0 ? void 0 : _navbarTranslations$.message) !== null && _navbarTranslations$$ !== void 0 ? _navbarTranslations$$ : subItem.label
56
+ label: ((_navbarTranslations$ = navbarTranslations[`item.label.${subItem.label}`]) === null || _navbarTranslations$ === void 0 ? void 0 : _navbarTranslations$.message) ?? subItem.label
59
57
  };
60
58
  });
61
59
  return { ...item,
62
- label: (_navbarTranslations$$2 = (_navbarTranslations$2 = navbarTranslations[`item.label.${item.label}`]) === null || _navbarTranslations$2 === void 0 ? void 0 : _navbarTranslations$2.message) !== null && _navbarTranslations$$2 !== void 0 ? _navbarTranslations$$2 : item.label,
60
+ label: ((_navbarTranslations$2 = navbarTranslations[`item.label.${item.label}`]) === null || _navbarTranslations$2 === void 0 ? void 0 : _navbarTranslations$2.message) ?? item.label,
63
61
  ...(subItems ? {
64
62
  items: subItems
65
63
  } : undefined)
@@ -77,14 +75,10 @@ function getFooterTranslationFile(footer) {
77
75
  message: link.title,
78
76
  description: `The title of the footer links column with title=${link.title} in the footer`
79
77
  })).value();
80
- const footerLinkLabels = (0, _lodash.chain)(isMultiColumnFooterLinks(footer.links) ? footer.links.flatMap(link => link.items).filter(link => !!link.label) : footer.links.filter(link => !!link.label)).keyBy(linkItem => `link.item.label.${linkItem.label}`).mapValues(linkItem => {
81
- var _linkItem$to;
82
-
83
- return {
84
- message: linkItem.label,
85
- description: `The label of footer link with label=${linkItem.label} linking to ${(_linkItem$to = linkItem.to) !== null && _linkItem$to !== void 0 ? _linkItem$to : linkItem.href}`
86
- };
87
- }).value();
78
+ const footerLinkLabels = (0, _lodash.chain)(isMultiColumnFooterLinks(footer.links) ? footer.links.flatMap(link => link.items).filter(link => !!link.label) : footer.links.filter(link => !!link.label)).keyBy(linkItem => `link.item.label.${linkItem.label}`).mapValues(linkItem => ({
79
+ message: linkItem.label,
80
+ description: `The label of footer link with label=${linkItem.label} linking to ${linkItem.to ?? linkItem.href}`
81
+ })).value();
88
82
  const copyright = footer.copyright ? {
89
83
  copyright: {
90
84
  message: footer.copyright,
@@ -95,29 +89,29 @@ function getFooterTranslationFile(footer) {
95
89
  }
96
90
 
97
91
  function translateFooter(footer, footerTranslations) {
98
- var _footerTranslations$c, _footerTranslations$c2;
92
+ var _footerTranslations$c;
99
93
 
100
94
  const links = isMultiColumnFooterLinks(footer.links) ? footer.links.map(link => {
101
- var _footerTranslations$$, _footerTranslations$;
95
+ var _footerTranslations$;
102
96
 
103
97
  return { ...link,
104
- title: (_footerTranslations$$ = (_footerTranslations$ = footerTranslations[`link.title.${link.title}`]) === null || _footerTranslations$ === void 0 ? void 0 : _footerTranslations$.message) !== null && _footerTranslations$$ !== void 0 ? _footerTranslations$$ : link.title,
98
+ title: ((_footerTranslations$ = footerTranslations[`link.title.${link.title}`]) === null || _footerTranslations$ === void 0 ? void 0 : _footerTranslations$.message) ?? link.title,
105
99
  items: link.items.map(linkItem => {
106
- var _footerTranslations$$2, _footerTranslations$2;
100
+ var _footerTranslations$2;
107
101
 
108
102
  return { ...linkItem,
109
- label: (_footerTranslations$$2 = (_footerTranslations$2 = footerTranslations[`link.item.label.${linkItem.label}`]) === null || _footerTranslations$2 === void 0 ? void 0 : _footerTranslations$2.message) !== null && _footerTranslations$$2 !== void 0 ? _footerTranslations$$2 : linkItem.label
103
+ label: ((_footerTranslations$2 = footerTranslations[`link.item.label.${linkItem.label}`]) === null || _footerTranslations$2 === void 0 ? void 0 : _footerTranslations$2.message) ?? linkItem.label
110
104
  };
111
105
  })
112
106
  };
113
107
  }) : footer.links.map(link => {
114
- var _footerTranslations$$3, _footerTranslations$3;
108
+ var _footerTranslations$3;
115
109
 
116
110
  return { ...link,
117
- label: (_footerTranslations$$3 = (_footerTranslations$3 = footerTranslations[`link.item.label.${link.label}`]) === null || _footerTranslations$3 === void 0 ? void 0 : _footerTranslations$3.message) !== null && _footerTranslations$$3 !== void 0 ? _footerTranslations$$3 : link.label
111
+ label: ((_footerTranslations$3 = footerTranslations[`link.item.label.${link.label}`]) === null || _footerTranslations$3 === void 0 ? void 0 : _footerTranslations$3.message) ?? link.label
118
112
  };
119
113
  });
120
- const copyright = (_footerTranslations$c = (_footerTranslations$c2 = footerTranslations.copyright) === null || _footerTranslations$c2 === void 0 ? void 0 : _footerTranslations$c2.message) !== null && _footerTranslations$c !== void 0 ? _footerTranslations$c : footer.copyright;
114
+ const copyright = ((_footerTranslations$c = footerTranslations.copyright) === null || _footerTranslations$c === void 0 ? void 0 : _footerTranslations$c.message) ?? footer.copyright;
121
115
  return { ...footer,
122
116
  links,
123
117
  copyright
@@ -4,28 +4,25 @@
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 ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
8
7
  import siteConfig from '@generated/docusaurus.config';
9
8
 
10
9
  const prismIncludeLanguages = (PrismObject) => {
11
- if (ExecutionEnvironment.canUseDOM) {
12
- const {
13
- themeConfig: {prism},
14
- } = siteConfig;
15
- const {additionalLanguages} = prism; // Prism components work on the Prism instance on the window, while
16
- // prism-react-renderer uses its own Prism instance. We temporarily mount
17
- // the instance onto window, import components to enhance it, then remove it
18
- // to avoid polluting global namespace.
19
- // You can mutate this object: registering plugins, deleting languages... As
20
- // long as you don't re-assign it
10
+ const {
11
+ themeConfig: {prism},
12
+ } = siteConfig;
13
+ const {additionalLanguages} = prism; // Prism components work on the Prism instance on the window, while prism-
14
+ // react-renderer uses its own Prism instance. We temporarily mount the
15
+ // instance onto window, import components to enhance it, then remove it to
16
+ // avoid polluting global namespace.
17
+ // You can mutate PrismObject: registering plugins, deleting languages... As
18
+ // long as you don't re-assign it
21
19
 
22
- window.Prism = PrismObject;
23
- additionalLanguages.forEach((lang) => {
24
- // eslint-disable-next-line global-require, import/no-dynamic-require
25
- require(`prismjs/components/prism-${lang}`);
26
- });
27
- delete window.Prism;
28
- }
20
+ globalThis.Prism = PrismObject;
21
+ additionalLanguages.forEach((lang) => {
22
+ // eslint-disable-next-line global-require, import/no-dynamic-require
23
+ require(`prismjs/components/prism-${lang}`);
24
+ });
25
+ delete globalThis.Prism;
29
26
  };
30
27
 
31
28
  export default prismIncludeLanguages;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4554",
3
+ "version": "0.0.0-4559",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -21,16 +21,16 @@
21
21
  "format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
22
22
  },
23
23
  "dependencies": {
24
- "@docusaurus/core": "0.0.0-4554",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4554",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4554",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4554",
28
- "@docusaurus/theme-common": "0.0.0-4554",
29
- "@docusaurus/theme-translations": "0.0.0-4554",
30
- "@docusaurus/utils": "0.0.0-4554",
31
- "@docusaurus/utils-common": "0.0.0-4554",
32
- "@docusaurus/utils-validation": "0.0.0-4554",
33
- "@mdx-js/react": "^1.6.21",
24
+ "@docusaurus/core": "0.0.0-4559",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4559",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4559",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4559",
28
+ "@docusaurus/theme-common": "0.0.0-4559",
29
+ "@docusaurus/theme-translations": "0.0.0-4559",
30
+ "@docusaurus/utils": "0.0.0-4559",
31
+ "@docusaurus/utils-common": "0.0.0-4559",
32
+ "@docusaurus/utils-validation": "0.0.0-4559",
33
+ "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
36
36
  "infima": "0.2.0-alpha.37",
@@ -42,8 +42,8 @@
42
42
  "rtlcss": "^3.3.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4554",
46
- "@docusaurus/types": "0.0.0-4554",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4559",
46
+ "@docusaurus/types": "0.0.0-4559",
47
47
  "@types/mdx-js__react": "^1.5.4",
48
48
  "@types/parse-numeric-range": "^0.0.1",
49
49
  "@types/prismjs": "^1.26.0",
@@ -54,13 +54,11 @@
54
54
  "utility-types": "^3.10.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "@babel/core": "^7.0.0",
58
57
  "react": "^16.8.4 || ^17.0.0",
59
- "react-dom": "^16.8.4 || ^17.0.0",
60
- "webpack": "^5.0.0"
58
+ "react-dom": "^16.8.4 || ^17.0.0"
61
59
  },
62
60
  "engines": {
63
61
  "node": ">=14"
64
62
  },
65
- "gitHead": "d599cd10202242196737527108e8a15beef1443d"
63
+ "gitHead": "047c6bc9a21dbbfbd8d9153cac7d6a4cecb6c00f"
66
64
  }
@@ -5,32 +5,29 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
9
8
  import siteConfig from '@generated/docusaurus.config';
10
9
  import type * as PrismNamespace from 'prismjs';
11
10
 
12
11
  const prismIncludeLanguages = (PrismObject: typeof PrismNamespace): void => {
13
- if (ExecutionEnvironment.canUseDOM) {
14
- const {
15
- themeConfig: {prism},
16
- } = siteConfig;
17
- const {additionalLanguages} = prism as {additionalLanguages: string[]};
12
+ const {
13
+ themeConfig: {prism},
14
+ } = siteConfig;
15
+ const {additionalLanguages} = prism as {additionalLanguages: string[]};
18
16
 
19
- // Prism components work on the Prism instance on the window, while
20
- // prism-react-renderer uses its own Prism instance. We temporarily mount
21
- // the instance onto window, import components to enhance it, then remove it
22
- // to avoid polluting global namespace.
23
- // You can mutate this object: registering plugins, deleting languages... As
24
- // long as you don't re-assign it
25
- window.Prism = PrismObject;
17
+ // Prism components work on the Prism instance on the window, while prism-
18
+ // react-renderer uses its own Prism instance. We temporarily mount the
19
+ // instance onto window, import components to enhance it, then remove it to
20
+ // avoid polluting global namespace.
21
+ // You can mutate PrismObject: registering plugins, deleting languages... As
22
+ // long as you don't re-assign it
23
+ globalThis.Prism = PrismObject;
26
24
 
27
- additionalLanguages.forEach((lang) => {
28
- // eslint-disable-next-line global-require, import/no-dynamic-require
29
- require(`prismjs/components/prism-${lang}`);
30
- });
25
+ additionalLanguages.forEach((lang) => {
26
+ // eslint-disable-next-line global-require, import/no-dynamic-require
27
+ require(`prismjs/components/prism-${lang}`);
28
+ });
31
29
 
32
- delete (window as Window & {Prism?: typeof PrismNamespace}).Prism;
33
- }
30
+ delete (globalThis as Global & {Prism?: typeof PrismNamespace}).Prism;
34
31
  };
35
32
 
36
33
  export default prismIncludeLanguages;