@docusaurus/theme-classic 0.0.0-5627 → 0.0.0-5632
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.
|
@@ -23,9 +23,15 @@ import SearchMetadata from '@theme/SearchMetadata';
|
|
|
23
23
|
// See https://github.com/facebook/docusaurus/issues/3317
|
|
24
24
|
function AlternateLangHeaders() {
|
|
25
25
|
const {
|
|
26
|
-
i18n: {defaultLocale, localeConfigs},
|
|
26
|
+
i18n: {currentLocale, defaultLocale, localeConfigs},
|
|
27
27
|
} = useDocusaurusContext();
|
|
28
28
|
const alternatePageUtils = useAlternatePageUtils();
|
|
29
|
+
const currentHtmlLang = localeConfigs[currentLocale].htmlLang;
|
|
30
|
+
// HTML lang is a BCP 47 tag, but the Open Graph protocol requires
|
|
31
|
+
// using underscores instead of dashes.
|
|
32
|
+
// See https://ogp.me/#optional
|
|
33
|
+
// See https://en.wikipedia.org/wiki/IETF_language_tag)
|
|
34
|
+
const bcp47ToOpenGraphLocale = (code) => code.replace('-', '_');
|
|
29
35
|
// Note: it is fine to use both "x-default" and "en" to target the same url
|
|
30
36
|
// See https://www.searchviu.com/en/multiple-hreflang-tags-one-url/
|
|
31
37
|
return (
|
|
@@ -49,6 +55,20 @@ function AlternateLangHeaders() {
|
|
|
49
55
|
})}
|
|
50
56
|
hrefLang="x-default"
|
|
51
57
|
/>
|
|
58
|
+
|
|
59
|
+
<meta
|
|
60
|
+
property="og:locale"
|
|
61
|
+
content={bcp47ToOpenGraphLocale(currentHtmlLang)}
|
|
62
|
+
/>
|
|
63
|
+
{Object.values(localeConfigs)
|
|
64
|
+
.filter((config) => currentHtmlLang !== config.htmlLang)
|
|
65
|
+
.map((config) => (
|
|
66
|
+
<meta
|
|
67
|
+
key={`meta-og-${config.htmlLang}`}
|
|
68
|
+
property="og:locale:alternate"
|
|
69
|
+
content={bcp47ToOpenGraphLocale(config.htmlLang)}
|
|
70
|
+
/>
|
|
71
|
+
))}
|
|
52
72
|
</Head>
|
|
53
73
|
);
|
|
54
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5632",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "0.0.0-
|
|
24
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
25
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
28
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
30
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
31
|
-
"@docusaurus/types": "0.0.0-
|
|
32
|
-
"@docusaurus/utils": "0.0.0-
|
|
33
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
34
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
23
|
+
"@docusaurus/core": "0.0.0-5632",
|
|
24
|
+
"@docusaurus/mdx-loader": "0.0.0-5632",
|
|
25
|
+
"@docusaurus/module-type-aliases": "0.0.0-5632",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "0.0.0-5632",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "0.0.0-5632",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "0.0.0-5632",
|
|
29
|
+
"@docusaurus/theme-common": "0.0.0-5632",
|
|
30
|
+
"@docusaurus/theme-translations": "0.0.0-5632",
|
|
31
|
+
"@docusaurus/types": "0.0.0-5632",
|
|
32
|
+
"@docusaurus/utils": "0.0.0-5632",
|
|
33
|
+
"@docusaurus/utils-common": "0.0.0-5632",
|
|
34
|
+
"@docusaurus/utils-validation": "0.0.0-5632",
|
|
35
35
|
"@mdx-js/react": "^2.1.5",
|
|
36
36
|
"clsx": "^1.2.1",
|
|
37
37
|
"copy-text-to-clipboard": "^3.2.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=16.14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "89bc98ec99d8d5d44e5b8503774f55ac0cb7d8d1"
|
|
66
66
|
}
|
|
@@ -25,10 +25,19 @@ import SearchMetadata from '@theme/SearchMetadata';
|
|
|
25
25
|
// See https://github.com/facebook/docusaurus/issues/3317
|
|
26
26
|
function AlternateLangHeaders(): JSX.Element {
|
|
27
27
|
const {
|
|
28
|
-
i18n: {defaultLocale, localeConfigs},
|
|
28
|
+
i18n: {currentLocale, defaultLocale, localeConfigs},
|
|
29
29
|
} = useDocusaurusContext();
|
|
30
30
|
const alternatePageUtils = useAlternatePageUtils();
|
|
31
31
|
|
|
32
|
+
const currentHtmlLang = localeConfigs[currentLocale]!.htmlLang;
|
|
33
|
+
|
|
34
|
+
// HTML lang is a BCP 47 tag, but the Open Graph protocol requires
|
|
35
|
+
// using underscores instead of dashes.
|
|
36
|
+
// See https://ogp.me/#optional
|
|
37
|
+
// See https://en.wikipedia.org/wiki/IETF_language_tag)
|
|
38
|
+
const bcp47ToOpenGraphLocale = (code: string): string =>
|
|
39
|
+
code.replace('-', '_');
|
|
40
|
+
|
|
32
41
|
// Note: it is fine to use both "x-default" and "en" to target the same url
|
|
33
42
|
// See https://www.searchviu.com/en/multiple-hreflang-tags-one-url/
|
|
34
43
|
return (
|
|
@@ -52,6 +61,20 @@ function AlternateLangHeaders(): JSX.Element {
|
|
|
52
61
|
})}
|
|
53
62
|
hrefLang="x-default"
|
|
54
63
|
/>
|
|
64
|
+
|
|
65
|
+
<meta
|
|
66
|
+
property="og:locale"
|
|
67
|
+
content={bcp47ToOpenGraphLocale(currentHtmlLang)}
|
|
68
|
+
/>
|
|
69
|
+
{Object.values(localeConfigs)
|
|
70
|
+
.filter((config) => currentHtmlLang !== config.htmlLang)
|
|
71
|
+
.map((config) => (
|
|
72
|
+
<meta
|
|
73
|
+
key={`meta-og-${config.htmlLang}`}
|
|
74
|
+
property="og:locale:alternate"
|
|
75
|
+
content={bcp47ToOpenGraphLocale(config.htmlLang)}
|
|
76
|
+
/>
|
|
77
|
+
))}
|
|
55
78
|
</Head>
|
|
56
79
|
);
|
|
57
80
|
}
|