@docusaurus/theme-common 2.4.1 → 2.4.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlternatePageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"useAlternatePageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI;IACvC;;;;OAIG;IACH,SAAS,EAAE,CAAC;IACV,kCAAkC;IAClC,MAAM;IACN;;;;OAIG;IACH,cAAc,GACf,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,OAAO,CAAC;KACzB,KAAK,MAAM,CAAC;CACd,CA2CA"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
8
8
|
import { useLocation } from '@docusaurus/router';
|
|
9
|
+
import { applyTrailingSlash } from '@docusaurus/utils-common';
|
|
9
10
|
/**
|
|
10
11
|
* Permits to obtain the url of the current page in another locale, useful to
|
|
11
12
|
* generate hreflang meta headers etc...
|
|
@@ -13,12 +14,18 @@ import { useLocation } from '@docusaurus/router';
|
|
|
13
14
|
* @see https://developers.google.com/search/docs/advanced/crawling/localized-versions
|
|
14
15
|
*/
|
|
15
16
|
export function useAlternatePageUtils() {
|
|
16
|
-
const { siteConfig: { baseUrl, url }, i18n: { defaultLocale, currentLocale }, } = useDocusaurusContext();
|
|
17
|
+
const { siteConfig: { baseUrl, url, trailingSlash }, i18n: { defaultLocale, currentLocale }, } = useDocusaurusContext();
|
|
18
|
+
// TODO using useLocation().pathname is not a super idea
|
|
19
|
+
// See https://github.com/facebook/docusaurus/issues/9170
|
|
17
20
|
const { pathname } = useLocation();
|
|
21
|
+
const canonicalPathname = applyTrailingSlash(pathname, {
|
|
22
|
+
trailingSlash,
|
|
23
|
+
baseUrl,
|
|
24
|
+
});
|
|
18
25
|
const baseUrlUnlocalized = currentLocale === defaultLocale
|
|
19
26
|
? baseUrl
|
|
20
27
|
: baseUrl.replace(`/${currentLocale}/`, '/');
|
|
21
|
-
const pathnameSuffix =
|
|
28
|
+
const pathnameSuffix = canonicalPathname.replace(baseUrl, '');
|
|
22
29
|
function getLocalizedBaseUrl(locale) {
|
|
23
30
|
return locale === defaultLocale
|
|
24
31
|
? `${baseUrlUnlocalized}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlternatePageUtils.js","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"useAlternatePageUtils.js","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IAoBnC,MAAM,EACJ,UAAU,EAAE,EAAC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAC,EACzC,IAAI,EAAE,EAAC,aAAa,EAAE,aAAa,EAAC,GACrC,GAAG,oBAAoB,EAAE,CAAC;IAE3B,wDAAwD;IACxD,yDAAyD;IACzD,MAAM,EAAC,QAAQ,EAAC,GAAG,WAAW,EAAE,CAAC;IAEjC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,QAAQ,EAAE;QACrD,aAAa;QACb,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,kBAAkB,GACtB,aAAa,KAAK,aAAa;QAC7B,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,aAAa,GAAG,EAAE,GAAG,CAAC,CAAC;IAEjD,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAE9D,SAAS,mBAAmB,CAAC,MAAc;QACzC,OAAO,MAAM,KAAK,aAAa;YAC7B,CAAC,CAAC,GAAG,kBAAkB,EAAE;YACzB,CAAC,CAAC,GAAG,kBAAkB,GAAG,MAAM,GAAG,CAAC;IACxC,CAAC;IAED,wEAAwE;IACxE,iBAAiB;IACjB,SAAS,SAAS,CAAC,EACjB,MAAM,EACN,cAAc,GAIf;QACC,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,mBAAmB,CACvD,MAAM,CACP,GAAG,cAAc,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,EAAC,SAAS,EAAC,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-common",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "Common code for Docusaurus themes.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@docusaurus/mdx-loader": "2.4.
|
|
34
|
-
"@docusaurus/module-type-aliases": "2.4.
|
|
35
|
-
"@docusaurus/plugin-content-blog": "2.4.
|
|
36
|
-
"@docusaurus/plugin-content-docs": "2.4.
|
|
37
|
-
"@docusaurus/plugin-content-pages": "2.4.
|
|
38
|
-
"@docusaurus/utils": "2.4.
|
|
39
|
-
"@docusaurus/utils-common": "2.4.
|
|
33
|
+
"@docusaurus/mdx-loader": "2.4.3",
|
|
34
|
+
"@docusaurus/module-type-aliases": "2.4.3",
|
|
35
|
+
"@docusaurus/plugin-content-blog": "2.4.3",
|
|
36
|
+
"@docusaurus/plugin-content-docs": "2.4.3",
|
|
37
|
+
"@docusaurus/plugin-content-pages": "2.4.3",
|
|
38
|
+
"@docusaurus/utils": "2.4.3",
|
|
39
|
+
"@docusaurus/utils-common": "2.4.3",
|
|
40
40
|
"@types/history": "^4.7.11",
|
|
41
41
|
"@types/react": "*",
|
|
42
42
|
"@types/react-router-config": "*",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"utility-types": "^3.10.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@docusaurus/core": "2.4.
|
|
52
|
-
"@docusaurus/types": "2.4.
|
|
51
|
+
"@docusaurus/core": "2.4.3",
|
|
52
|
+
"@docusaurus/types": "2.4.3",
|
|
53
53
|
"fs-extra": "^10.1.0",
|
|
54
54
|
"lodash": "^4.17.21"
|
|
55
55
|
},
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=16.14"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "56410aa94665699f75cb889f477ccdffb98f2b21"
|
|
64
64
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
9
9
|
import {useLocation} from '@docusaurus/router';
|
|
10
|
+
import {applyTrailingSlash} from '@docusaurus/utils-common';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Permits to obtain the url of the current page in another locale, useful to
|
|
@@ -35,17 +36,25 @@ export function useAlternatePageUtils(): {
|
|
|
35
36
|
}) => string;
|
|
36
37
|
} {
|
|
37
38
|
const {
|
|
38
|
-
siteConfig: {baseUrl, url},
|
|
39
|
+
siteConfig: {baseUrl, url, trailingSlash},
|
|
39
40
|
i18n: {defaultLocale, currentLocale},
|
|
40
41
|
} = useDocusaurusContext();
|
|
42
|
+
|
|
43
|
+
// TODO using useLocation().pathname is not a super idea
|
|
44
|
+
// See https://github.com/facebook/docusaurus/issues/9170
|
|
41
45
|
const {pathname} = useLocation();
|
|
42
46
|
|
|
47
|
+
const canonicalPathname = applyTrailingSlash(pathname, {
|
|
48
|
+
trailingSlash,
|
|
49
|
+
baseUrl,
|
|
50
|
+
});
|
|
51
|
+
|
|
43
52
|
const baseUrlUnlocalized =
|
|
44
53
|
currentLocale === defaultLocale
|
|
45
54
|
? baseUrl
|
|
46
55
|
: baseUrl.replace(`/${currentLocale}/`, '/');
|
|
47
56
|
|
|
48
|
-
const pathnameSuffix =
|
|
57
|
+
const pathnameSuffix = canonicalPathname.replace(baseUrl, '');
|
|
49
58
|
|
|
50
59
|
function getLocalizedBaseUrl(locale: string) {
|
|
51
60
|
return locale === defaultLocale
|