Skip to content
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

Support doc page redirects for ALL services #3613

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions docs/source/_static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const nonResourceSubHeadings = [
'examples'
];
// Checks if an html doc name matches a service class name.
function isValidServiceName(docName, serviceClassName) {
const newDocName = docName.replaceAll('-', '').toLowerCase();
return newDocName === serviceClassName;
function isValidServiceName(serviceClassName) {
const pageTitle = document.getElementsByTagName('h1')[0];
const newDocName = pageTitle.getElementsByTagName('a')[0].innerHTML;
return newDocName.toLowerCase() === serviceClassName;
}
// Checks if all elements of the split fragment are valid.
// Fragment items should only contain alphanumerics, hyphens, & underscores.
Expand Down Expand Up @@ -58,7 +59,7 @@ function isValidResource(name, serviceDocName) {
splitFragment[1] = splitFragment[1].toLowerCase();
}
let newPath;
if (splitFragment.length >= 3 && isValidServiceName(serviceDocName, splitFragment[0])) {
if (splitFragment.length >= 3 && isValidServiceName(splitFragment[0])) {
splitFragment[0] = serviceDocName;
newPath = `${ splitFragment.slice(0, 3).join('/') }.html#${ splitFragment.length > 3 ? fragment : '' }`;
} else if (splitFragment.length == 2 && isValidResource(splitFragment[1].toLowerCase(), serviceDocName)) {
Expand Down