@docusaurus/core 0.0.0-5936 → 0.0.0-5939

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.
@@ -78,7 +78,15 @@ function createBrokenLinksHelper({ collectedLinks, routes, }) {
78
78
  if (hash === '') {
79
79
  return false;
80
80
  }
81
- const targetPage = collectedLinks.get(pathname) || collectedLinks.get(decodeURI(pathname));
81
+ const targetPage = collectedLinks.get(pathname) ??
82
+ collectedLinks.get(decodeURI(pathname)) ??
83
+ // The broken link checker should not care about a trailing slash
84
+ // Those are already covered by the broken pathname checker
85
+ // See https://github.com/facebook/docusaurus/issues/10116
86
+ collectedLinks.get((0, utils_common_1.addTrailingSlash)(pathname)) ??
87
+ collectedLinks.get((0, utils_common_1.addTrailingSlash)(decodeURI(pathname))) ??
88
+ collectedLinks.get((0, utils_common_1.removeTrailingSlash)(pathname)) ??
89
+ collectedLinks.get((0, utils_common_1.removeTrailingSlash)(decodeURI(pathname)));
82
90
  // link with anchor to a page that does not exist (or did not collect any
83
91
  // link/anchor) is considered as a broken anchor
84
92
  if (!targetPage) {
@@ -10,8 +10,32 @@ exports.loadI18n = exports.getDefaultLocaleConfig = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
12
  const rtl_detect_1 = require("rtl-detect");
13
+ function inferLanguageDisplayName(locale) {
14
+ const tryLocale = (l) => {
15
+ try {
16
+ return new Intl.DisplayNames(l, {
17
+ type: 'language',
18
+ fallback: 'code',
19
+ }).of(l);
20
+ }
21
+ catch (e) {
22
+ // This is to compensate "of()" that is a bit strict
23
+ // Looks like starting Node 22, this locale throws: "en-US-u-ca-buddhist"
24
+ // RangeError: invalid_argument
25
+ return null;
26
+ }
27
+ };
28
+ const parts = locale.split('-');
29
+ // This is a best effort, we try various locale forms that could give a result
30
+ return (tryLocale(locale) ??
31
+ tryLocale(`${parts[0]}-${parts[1]}`) ??
32
+ tryLocale(parts[0]));
33
+ }
13
34
  function getDefaultLocaleLabel(locale) {
14
- const languageName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale);
35
+ const languageName = inferLanguageDisplayName(locale);
36
+ if (!languageName) {
37
+ return locale;
38
+ }
15
39
  return (languageName.charAt(0).toLocaleUpperCase(locale) + languageName.substring(1));
16
40
  }
17
41
  function getDefaultCalendar(localeStr) {
@@ -34,13 +58,18 @@ function getDefaultCalendar(localeStr) {
34
58
  return 'gregory';
35
59
  }
36
60
  function getDefaultLocaleConfig(locale) {
37
- return {
38
- label: getDefaultLocaleLabel(locale),
39
- direction: (0, rtl_detect_1.getLangDir)(locale),
40
- htmlLang: locale,
41
- calendar: getDefaultCalendar(locale),
42
- path: locale,
43
- };
61
+ try {
62
+ return {
63
+ label: getDefaultLocaleLabel(locale),
64
+ direction: (0, rtl_detect_1.getLangDir)(locale),
65
+ htmlLang: locale,
66
+ calendar: getDefaultCalendar(locale),
67
+ path: locale,
68
+ };
69
+ }
70
+ catch (e) {
71
+ throw new Error(`Docusaurus couldn't get default locale config for ${locale}`, { cause: e });
72
+ }
44
73
  }
45
74
  exports.getDefaultLocaleConfig = getDefaultLocaleConfig;
46
75
  async function loadI18n(config, options) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "0.0.0-5936",
4
+ "version": "0.0.0-5939",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,12 +43,12 @@
43
43
  "@babel/runtime": "^7.22.6",
44
44
  "@babel/runtime-corejs3": "^7.22.6",
45
45
  "@babel/traverse": "^7.22.8",
46
- "@docusaurus/cssnano-preset": "0.0.0-5936",
47
- "@docusaurus/logger": "0.0.0-5936",
48
- "@docusaurus/mdx-loader": "0.0.0-5936",
49
- "@docusaurus/utils": "0.0.0-5936",
50
- "@docusaurus/utils-common": "0.0.0-5936",
51
- "@docusaurus/utils-validation": "0.0.0-5936",
46
+ "@docusaurus/cssnano-preset": "0.0.0-5939",
47
+ "@docusaurus/logger": "0.0.0-5939",
48
+ "@docusaurus/mdx-loader": "0.0.0-5939",
49
+ "@docusaurus/utils": "0.0.0-5939",
50
+ "@docusaurus/utils-common": "0.0.0-5939",
51
+ "@docusaurus/utils-validation": "0.0.0-5939",
52
52
  "autoprefixer": "^10.4.14",
53
53
  "babel-loader": "^9.1.3",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
@@ -103,8 +103,8 @@
103
103
  "webpackbar": "^5.0.2"
104
104
  },
105
105
  "devDependencies": {
106
- "@docusaurus/module-type-aliases": "0.0.0-5936",
107
- "@docusaurus/types": "0.0.0-5936",
106
+ "@docusaurus/module-type-aliases": "0.0.0-5939",
107
+ "@docusaurus/types": "0.0.0-5939",
108
108
  "@total-typescript/shoehorn": "^0.1.2",
109
109
  "@types/detect-port": "^1.3.3",
110
110
  "@types/react-dom": "^18.2.7",
@@ -124,5 +124,5 @@
124
124
  "engines": {
125
125
  "node": ">=18.0"
126
126
  },
127
- "gitHead": "81d636811c314ae20dff95589df890d8bfe1b574"
127
+ "gitHead": "e192aae8dee40f308af03a5e2050407cbd285c7d"
128
128
  }