This is an automated email from the ASF dual-hosted git repository.
jeffreyh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new f23632df331 fix:Solve the problem of URL automatically carrying
slashes causing dead links (#1341)
f23632df331 is described below
commit f23632df3312d69dc78a19f458b3fef3114671f8
Author: yangon <[email protected]>
AuthorDate: Thu Nov 14 16:36:38 2024 +0800
fix:Solve the problem of URL automatically carrying slashes causing dead
links (#1341)
Remove the slash from the URL.

Co-authored-by: liyang <[email protected]>
---
src/theme/Navbar/Layout/index.tsx | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/theme/Navbar/Layout/index.tsx
b/src/theme/Navbar/Layout/index.tsx
index 2e447e2e5bc..b9632cf47d1 100644
--- a/src/theme/Navbar/Layout/index.tsx
+++ b/src/theme/Navbar/Layout/index.tsx
@@ -5,10 +5,13 @@ import { useHideableNavbar, useNavbarMobileSidebar } from
'@docusaurus/theme-com
import { translate } from '@docusaurus/Translate';
import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
import styles from './styles.module.css';
+import { useLocation } from '@docusaurus/router';
+
function NavbarBackdrop(props) {
return <div role="presentation" {...props}
className={clsx('navbar-sidebar__backdrop', props.className)} />;
}
export default function NavbarLayout({ children }) {
+ const location = useLocation();
const {
navbar: { hideOnScroll, style },
} = useThemeConfig();
@@ -22,11 +25,12 @@ export default function NavbarLayout({ children }) {
useEffect(() => {
if (typeof window !== 'undefined') {
const pathname = location.pathname.split('/')[1];
- const tempPath = ['get-starting', 'benchmark', 'ecosystems',
'faq', 'releasenotes']
- const isDocsPage = tempPath.includes(pathname) ||
tempPath.some(path => location.pathname.includes(`zh-CN/${path}`))
+ const tempPath = ['get-starting', 'benchmark', 'ecosystems',
'faq', 'releasenotes'];
+ const isDocsPage =
+ tempPath.includes(pathname) || tempPath.some(path =>
location.pathname.includes(`zh-CN/${path}`));
const docsPage = pathname === 'docs' ||
location.pathname.includes('zh-CN/docs');
setIsDocsPage(docsPage);
- setWithoutDoc(isDocsPage)
+ setWithoutDoc(isDocsPage);
}
if (typeof window !== 'undefined') {
@@ -35,6 +39,17 @@ export default function NavbarLayout({ children }) {
setIsCommunity(communityPage);
}
}, [typeof window !== 'undefined' && location.pathname]);
+
+ useEffect(() => {
+ if (
+ typeof window !== 'undefined' &&
+ location.pathname.length > 1 &&
+ location.pathname[location.pathname.length - 1] === '/'
+ ) {
+ window.location.pathname = location.pathname.slice(0, -1);
+ }
+ }, [location.pathname]);
+
return (
<nav
ref={navbarRef}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]