Skip to content

Commit 5e3d3e0

Browse files
committed
Docs: Redirect /pages/ClassName.html to /#ClassName.
1 parent 258827b commit 5e3d3e0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/scripts/page.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
if ( ! window.frameElement && window.location.protocol !== 'file:' ) {
2+
3+
// navigates to docs home if direct access, e.g.
4+
// https://threejs.org/docs/pages/BoxGeometry.html
5+
// ->https://threejs.org/docs/#BoxGeometry
6+
7+
const url = new URL( window.location.href );
8+
9+
// hash route, e.g. #BoxGeometry
10+
url.hash = url.pathname.replace( /\/docs\/pages\/(.*?)(?:\.html)?$/, '$1' );
11+
12+
// docs home, e.g. https://threejs.org/docs/
13+
url.pathname = url.pathname.replace( /(\/docs\/).*$/, '$1' );
14+
15+
window.location.replace( url );
16+
17+
}
18+
119
// Initialize Highlight.js for syntax highlighting
220
if ( typeof hljs !== 'undefined' ) {
321

0 commit comments

Comments
 (0)