From 022f86aa28e1b470f004e0f5cdade1233219d8d0 Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:00:21 -0400 Subject: [PATCH] add site_url root path to images [Fixes #14435] --- docs/_static/js/constants.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/_static/js/constants.js b/docs/_static/js/constants.js index abdeb4464..67fa16cdb 100644 --- a/docs/_static/js/constants.js +++ b/docs/_static/js/constants.js @@ -1,11 +1,18 @@ +// Site URL +const SITE_URL = "https://docs.soliditylang.org" +const { origin, pathname } = location; +const pathSplit = pathname.split("/"); +const rootPath = origin.includes(SITE_URL) && pathSplit.length > 3 ? pathSplit.splice(1, 2).join("/") : '' +const ROOT_URL = `${origin}/${rootPath}`; + // Color mode constants const [DARK, LIGHT] = ["dark", "light"]; -const LIGHT_LOGO_PATH = "_static/img/logo.svg"; -const DARK_LOGO_PATH = "_static/img/logo-dark.svg"; -const SUN_ICON_PATH = "_static/img/sun.svg"; -const MOON_ICON_PATH = "_static/img/moon.svg"; -const LIGHT_HAMBURGER_PATH = "_static/img/hamburger-light.svg"; -const DARK_HAMBURGER_PATH = "_static/img/hamburger-dark.svg"; +const LIGHT_LOGO_PATH = `${ROOT_URL}/_static/img/logo.svg`; +const DARK_LOGO_PATH = `${ROOT_URL}/_static/img/logo-dark.svg`; +const SUN_ICON_PATH = `${ROOT_URL}/_static/img/sun.svg`; +const MOON_ICON_PATH = `${ROOT_URL}/_static/img/moon.svg`; +const LIGHT_HAMBURGER_PATH = `${ROOT_URL}/_static/img/hamburger-light.svg`; +const DARK_HAMBURGER_PATH = `${ROOT_URL}/_static/img/hamburger-dark.svg`; const COLOR_TOGGLE_ICON_CLASS = "color-toggle-icon"; const SOLIDITY_LOGO_CLASS = "solidity-logo"; const LS_COLOR_SCHEME = "color-scheme";