Only process relative links on RTD

This commit is contained in:
Marcel Stör 2019-02-11 22:52:17 +01:00
parent 30744afd24
commit f0a240aa46
1 changed files with 8 additions and 6 deletions

View File

@ -44,13 +44,15 @@ var nodemcu = nodemcu || {};
* replaces the relative path with an absolute path based on the selected branch.
*/
function replaceRelativeLinksWithStaticGitHubUrl() {
var relativePath = isOnRtd() ? "../../.." : "../..";
if (isOnRtd()) {
var relativePath = "../../..";
var gitHubPath = "https://github.com/nodemcu/nodemcu-firmware/tree/" + determineSelectedBranch();
var gitHubLinks = $("a[href^='" + relativePath + "']").each(function (index) {
var url = $(this).attr('href');
$(this).attr('href', url.replace(relativePath, gitHubPath));
});
}
}
/**
* Analyzes the URL of the current page to find out what the selected GitHub branch is. It's usually