@docusaurus/theme-classic 0.0.0-5626 → 0.0.0-5627

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.
@@ -15,6 +15,7 @@ import {
15
15
  keyboardFocusedClassName,
16
16
  } from '@docusaurus/theme-common/internal';
17
17
  import {useLocation} from '@docusaurus/router';
18
+ import {applyTrailingSlash} from '@docusaurus/utils-common';
18
19
  import SearchMetadata from '@theme/SearchMetadata';
19
20
  // TODO move to SiteMetadataDefaults or theme-common ?
20
21
  // Useful for i18n/SEO
@@ -54,10 +55,16 @@ function AlternateLangHeaders() {
54
55
  // Default canonical url inferred from current page location pathname
55
56
  function useDefaultCanonicalUrl() {
56
57
  const {
57
- siteConfig: {url: siteUrl},
58
+ siteConfig: {url: siteUrl, baseUrl, trailingSlash},
58
59
  } = useDocusaurusContext();
60
+ // TODO using useLocation().pathname is not a super idea
61
+ // See https://github.com/facebook/docusaurus/issues/9170
59
62
  const {pathname} = useLocation();
60
- return siteUrl + useBaseUrl(pathname);
63
+ const canonicalPathname = applyTrailingSlash(useBaseUrl(pathname), {
64
+ trailingSlash,
65
+ baseUrl,
66
+ });
67
+ return siteUrl + canonicalPathname;
61
68
  }
62
69
  // TODO move to SiteMetadataDefaults or theme-common ?
63
70
  function CanonicalUrlHeaders({permalink}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-5626",
3
+ "version": "0.0.0-5627",
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-5626",
24
- "@docusaurus/mdx-loader": "0.0.0-5626",
25
- "@docusaurus/module-type-aliases": "0.0.0-5626",
26
- "@docusaurus/plugin-content-blog": "0.0.0-5626",
27
- "@docusaurus/plugin-content-docs": "0.0.0-5626",
28
- "@docusaurus/plugin-content-pages": "0.0.0-5626",
29
- "@docusaurus/theme-common": "0.0.0-5626",
30
- "@docusaurus/theme-translations": "0.0.0-5626",
31
- "@docusaurus/types": "0.0.0-5626",
32
- "@docusaurus/utils": "0.0.0-5626",
33
- "@docusaurus/utils-common": "0.0.0-5626",
34
- "@docusaurus/utils-validation": "0.0.0-5626",
23
+ "@docusaurus/core": "0.0.0-5627",
24
+ "@docusaurus/mdx-loader": "0.0.0-5627",
25
+ "@docusaurus/module-type-aliases": "0.0.0-5627",
26
+ "@docusaurus/plugin-content-blog": "0.0.0-5627",
27
+ "@docusaurus/plugin-content-docs": "0.0.0-5627",
28
+ "@docusaurus/plugin-content-pages": "0.0.0-5627",
29
+ "@docusaurus/theme-common": "0.0.0-5627",
30
+ "@docusaurus/theme-translations": "0.0.0-5627",
31
+ "@docusaurus/types": "0.0.0-5627",
32
+ "@docusaurus/utils": "0.0.0-5627",
33
+ "@docusaurus/utils-common": "0.0.0-5627",
34
+ "@docusaurus/utils-validation": "0.0.0-5627",
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": "076431a4f8d43ab0c620ccbf2fcff42230a0c1ac"
65
+ "gitHead": "3d6546150cfcd7636d44dc5cfeb71d7f17deb735"
66
66
  }
@@ -16,6 +16,7 @@ import {
16
16
  keyboardFocusedClassName,
17
17
  } from '@docusaurus/theme-common/internal';
18
18
  import {useLocation} from '@docusaurus/router';
19
+ import {applyTrailingSlash} from '@docusaurus/utils-common';
19
20
  import SearchMetadata from '@theme/SearchMetadata';
20
21
 
21
22
  // TODO move to SiteMetadataDefaults or theme-common ?
@@ -58,10 +59,19 @@ function AlternateLangHeaders(): JSX.Element {
58
59
  // Default canonical url inferred from current page location pathname
59
60
  function useDefaultCanonicalUrl() {
60
61
  const {
61
- siteConfig: {url: siteUrl},
62
+ siteConfig: {url: siteUrl, baseUrl, trailingSlash},
62
63
  } = useDocusaurusContext();
64
+
65
+ // TODO using useLocation().pathname is not a super idea
66
+ // See https://github.com/facebook/docusaurus/issues/9170
63
67
  const {pathname} = useLocation();
64
- return siteUrl + useBaseUrl(pathname);
68
+
69
+ const canonicalPathname = applyTrailingSlash(useBaseUrl(pathname), {
70
+ trailingSlash,
71
+ baseUrl,
72
+ });
73
+
74
+ return siteUrl + canonicalPathname;
65
75
  }
66
76
 
67
77
  // TODO move to SiteMetadataDefaults or theme-common ?