Skip to content

Docs: Redirects for subpages implemented #10948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions docs/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,56 @@ var onDocumentLoad = function ( event ) {
break;

}


// redirect, if the page is not yet displayed as an iframe (with navigation panel and working links)

if ( !window.frameElement ) {

var redirectUrl;

for ( var mainCategory in list ) {

var subCategories = list[ mainCategory ];

for ( var subCategory in subCategories ) {

var pages = subCategories[ subCategory ]

for ( i = 0; i < pages.length; i++ ) {

var page = pages[ i ];

if ( page[ 1 ] === section + '/' + path ) {

redirectUrl = '#'
+ mainCategory
+ '/'
+ subCategory.replace(/\ \/\ /g, '.').replace(/\ /g, '_')
+ '/'
+ page[ 0 ].replace(/\ /g, '_');
break;

};

};

};

};

if ( redirectUrl ) {

window.location.replace( redirectUrl );

} else {

console.warn( 'Unknown URL - page can\'t be displayed as an inline frame.' )

}

}


var text = document.body.innerHTML;

Expand Down