diff --git a/docs/js/cards.js b/docs/js/cards.js new file mode 100644 index 00000000..c814821a --- /dev/null +++ b/docs/js/cards.js @@ -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); + }); +}); diff --git a/mkdocs.yml b/mkdocs.yml index 533d5b68..20beda85 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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: