File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
88const 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 ;
You can’t perform that action at this time.
0 commit comments