File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
docusaurus-theme-classic/src/theme/DocPage
docusaurus/src/client/exports Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 9
9
- Refactor dark toggle into a hook.
10
10
- Changed the way we read the ` USE_SSH ` env variable during deployment to be the same as in v1.
11
11
- Add highlight specific lines in code blocks.
12
+ - Fix accessing ` docs/ ` or ` /docs/xxxx ` that does not match any existing doc page should return 404 (Not found) page, not blank page.
12
13
13
14
## 2.0.0-alpha.31
14
15
Original file line number Diff line number Diff line change @@ -13,16 +13,26 @@ import renderRoutes from '@docusaurus/renderRoutes';
13
13
import Layout from '@theme/Layout' ;
14
14
import DocSidebar from '@theme/DocSidebar' ;
15
15
import MDXComponents from '@theme/MDXComponents' ;
16
+ import NotFound from '@theme/NotFound' ;
17
+ import { matchPath } from '@docusaurus/router' ;
16
18
17
19
import styles from './styles.module.css' ;
18
20
21
+ function matchingRouteExist ( routes , pathname ) {
22
+ return routes . some ( route => matchPath ( pathname , route ) ) ;
23
+ }
24
+
19
25
function DocPage ( props ) {
20
26
const { route, docsMetadata, location} = props ;
21
27
const { permalinkToSidebar, docsSidebars} = docsMetadata ;
22
28
const sidebar = permalinkToSidebar [ location . pathname . replace ( / \/ $ / , '' ) ] ;
23
29
const { siteConfig : { themeConfig = { } } = { } } = useDocusaurusContext ( ) ;
24
30
const { sidebarCollapsible = true } = themeConfig ;
25
31
32
+ if ( ! matchingRouteExist ( route . routes , location . pathname ) ) {
33
+ return < NotFound { ...props } /> ;
34
+ }
35
+
26
36
return (
27
37
< Layout >
28
38
< div className = { styles . docPage } >
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) 2017-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ export * from 'react-router-dom' ;
You can’t perform that action at this time.
0 commit comments