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

cards.js to fix links #287

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions docs/js/cards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$(function() {
let version_path_index = 4;
$('.card-wrapper > div > a').each(function() {
let destUrl = $(this).attr('href');
if ('//' === destUrl.substring(0, 2)) {
destUrl = document.location.protocol + destUrl;
} else if ('/' === destUrl.substring(0, 1)) {
destUrl = document.location.protocol + '//' + document.location.host + destUrl;
}
destUrl = new URL(destUrl);
let destPath = destUrl.pathname.split('/'),
srcPath = document.location.pathname.split('/');
if (destPath[version_path_index] !== srcPath[version_path_index]) {
destPath[version_path_index] = srcPath[version_path_index];
}
destUrl.pathname = destPath.join('/');
$(this).attr('href', destUrl.href);
});
});
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ extra_javascript:
- js/jquery-ui.min.js
- js/custom.js
- js/docs.switcher.js
- js/cards.js
- '//cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js'

markdown_extensions:
Expand Down