From 98833b267fba527b1533ff9cbce908c24a6271af Mon Sep 17 00:00:00 2001 From: minami Date: Mon, 25 Jul 2022 04:26:45 +0900 Subject: [PATCH] Fix dark mode bug --- docs/_static/js/toggle.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/_static/js/toggle.js b/docs/_static/js/toggle.js index f46a3a666..780ea9ee7 100644 --- a/docs/_static/js/toggle.js +++ b/docs/_static/js/toggle.js @@ -4,15 +4,16 @@ document.addEventListener('DOMContentLoaded', function() { var mode = (isDay ? "Day" : "Night"); localStorage.setItem("css-mode", mode); - var daysheet = $('link[href="_static/pygments.css"]')[0].sheet; + var url_root = DOCUMENTATION_OPTIONS.URL_ROOT == "./" ? "" : DOCUMENTATION_OPTIONS.URL_ROOT; + var daysheet = $(`link[href="${url_root}_static/pygments.css"]`)[0].sheet; daysheet.disabled = !isDay; - var nightsheet = $('link[href="_static/css/dark.css"]')[0]; + var nightsheet = $(`link[href="${url_root}_static/css/dark.css"]`)[0]; if (!isDay && nightsheet === undefined) { var element = document.createElement("link"); element.setAttribute("rel", "stylesheet"); element.setAttribute("type", "text/css"); - element.setAttribute("href", "_static/css/dark.css"); + element.setAttribute("href", `${url_root}_static/css/dark.css`); document.getElementsByTagName("head")[0].appendChild(element); return; }