This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git
The following commit(s) were added to refs/heads/main by this push:
new 0a5013acc41 fix redirections with/without trailing slash (#281)
0a5013acc41 is described below
commit 0a5013acc41c5dc8d81b0f0bb814b33b3297642d
Author: tison <[email protected]>
AuthorDate: Fri Nov 11 09:47:12 2022 +0800
fix redirections with/without trailing slash (#281)
Signed-off-by: tison <[email protected]>
---
site2/website-next/docs/cookbooks-encryption.md | 7 ++++---
site2/website-next/docs/schema-manage.md | 7 ++++---
site2/website-next/docs/standalone.md | 5 +++--
site2/website-next/src/libs/useLocationParentPath.js | 9 +++++++++
site2/website-next/versioned_docs/version-2.10.x/standalone.md | 5 +++--
5 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/site2/website-next/docs/cookbooks-encryption.md
b/site2/website-next/docs/cookbooks-encryption.md
index 9ea64d2a5c0..02e50d81e2f 100644
--- a/site2/website-next/docs/cookbooks-encryption.md
+++ b/site2/website-next/docs/cookbooks-encryption.md
@@ -5,7 +5,8 @@ sidebar_label: "Encryption"
---
````mdx-code-block
-import {Redirect} from '@docusaurus/router';
+import useLocationParentPath from '@site/src/libs/useLocationParentPath';
+import {Redirect} from "@docusaurus/router";
-<Redirect to="security-encryption#get-started" />
-````
\ No newline at end of file
+<Redirect to={useLocationParentPath() + "security-encryption#get-started"} />
+````
diff --git a/site2/website-next/docs/schema-manage.md
b/site2/website-next/docs/schema-manage.md
index 69311d10770..411ceeccbfd 100644
--- a/site2/website-next/docs/schema-manage.md
+++ b/site2/website-next/docs/schema-manage.md
@@ -5,7 +5,8 @@ sidebar_label: "Manage schema"
---
````mdx-code-block
-import {Redirect} from '@docusaurus/router';
+import useLocationParentPath from '@site/src/libs/useLocationParentPath';
+import {Redirect} from "@docusaurus/router";
-<Redirect to="admin-api-schemas" />
-````
\ No newline at end of file
+<Redirect to={useLocationParentPath() + "admin-api-schemas"} />
+````
diff --git a/site2/website-next/docs/standalone.md
b/site2/website-next/docs/standalone.md
index d1658b84cc2..0ddc3cd1617 100644
--- a/site2/website-next/docs/standalone.md
+++ b/site2/website-next/docs/standalone.md
@@ -5,7 +5,8 @@ sidebar_label: "Run Pulsar locally"
---
````mdx-code-block
-import {Redirect} from '@docusaurus/router';
+import useLocationParentPath from '@site/src/libs/useLocationParentPath';
+import {Redirect} from "@docusaurus/router";
-<Redirect to="getting-started-standalone" />
+<Redirect to={useLocationParentPath() + "getting-started-standalone"} />
````
diff --git a/site2/website-next/src/libs/useLocationParentPath.js
b/site2/website-next/src/libs/useLocationParentPath.js
new file mode 100644
index 00000000000..fc350a5be7c
--- /dev/null
+++ b/site2/website-next/src/libs/useLocationParentPath.js
@@ -0,0 +1,9 @@
+import {useLocation} from '@docusaurus/router';
+
+export default function useLocationParentPath() {
+ let {pathname} = useLocation();
+ if (pathname.endsWith('/')) {
+ pathname = pathname.slice(0, -1);
+ }
+ return pathname.slice(0, pathname.lastIndexOf("/")) + "/";
+}
diff --git a/site2/website-next/versioned_docs/version-2.10.x/standalone.md
b/site2/website-next/versioned_docs/version-2.10.x/standalone.md
index e279db20486..c07b8252944 100644
--- a/site2/website-next/versioned_docs/version-2.10.x/standalone.md
+++ b/site2/website-next/versioned_docs/version-2.10.x/standalone.md
@@ -6,7 +6,8 @@ original_id: standalone
---
````mdx-code-block
-import {Redirect} from '@docusaurus/router';
+import useLocationParentPath from '@site/src/libs/useLocationParentPath';
+import {Redirect} from "@docusaurus/router";
-<Redirect to="getting-started-standalone" />
+<Redirect to={useLocationParentPath() + "getting-started-standalone"} />
````