Skip to content

Commit 0f64dc5

Browse files
committed
temporary fix .html ending links on the client side
1 parent d32db6e commit 0f64dc5

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

website/src/theme/Layout.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ import {Redirect, useLocation} from '@docusaurus/router';
66
// See https://github.com/facebook/react-native-website/issues/2291
77
// Inspired by https://jasonwatmore.com/post/2020/03/23/react-router-remove-trailing-slash-from-urls
88
const RemoveTrailingSlashRedirect = () => {
9-
const location = useLocation();
10-
if (location.pathname.endsWith('/')) {
11-
return <Redirect to={location.pathname.slice(0, -1)} />;
9+
const {pathname} = useLocation();
10+
if (pathname.endsWith('/')) {
11+
return <Redirect to={pathname.slice(0, -1)} />;
12+
}
13+
if (pathname.endsWith('.html')) {
14+
return <Redirect to={pathname.slice(0, -5)} />;
1215
}
1316
return null;
1417
};
1518

16-
export default function Layout(props) {
17-
return (
18-
<>
19-
<RemoveTrailingSlashRedirect />
20-
<OriginalLayout {...props} />
21-
</>
22-
);
23-
}
19+
const Layout = props => (
20+
<>
21+
<RemoveTrailingSlashRedirect />
22+
<OriginalLayout {...props} />
23+
</>
24+
);
25+
26+
export default Layout;

0 commit comments

Comments
 (0)