From 83fe3d4011e3d14385f83aef0c32a0d894273501 Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Mon, 24 Jul 2023 07:48:39 -0700 Subject: [PATCH] update GH edit path to `develop` branch (#14437) --- docs/_static/js/initialize.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/_static/js/initialize.js b/docs/_static/js/initialize.js index c875b37df..04afa10e4 100644 --- a/docs/_static/js/initialize.js +++ b/docs/_static/js/initialize.js @@ -143,6 +143,19 @@ const updateActiveNavLink = () => { document.addEventListener("locationchange", updateActiveNavLink); +function updateGitHubEditPath() { + // Replaces the version number in the GitHub edit path with "develop" + const gitHubEditAnchor = document.querySelector(".wy-breadcrumbs-aside > a"); + const url = new URL(gitHubEditAnchor.href); + const split = url.pathname.split("/"); + const versionIndex = split.indexOf("blob") + 1; + split[versionIndex] = "develop"; + url.pathname = split.join("/"); + gitHubEditAnchor.setAttribute("href", url.toString()); + gitHubEditAnchor.setAttribute("target", "_blank"); + gitHubEditAnchor.setAttribute("rel", "noopener noreferrer"); +} + function initialize() { // Preload fonts const fonts = [ @@ -214,6 +227,9 @@ function initialize() { // Update active nav link updateActiveNavLink(); + + // Update GitHub edit path to direct to `develop` branch + updateGitHubEditPath(); } document.addEventListener("DOMContentLoaded", initialize);