From 026ce73ef8c92be67450fd7f7587665092fbd23f Mon Sep 17 00:00:00 2001 From: Francisco Javier Arceo Date: Wed, 9 Apr 2025 11:59:39 -0400 Subject: [PATCH] adding some js to detect current browser theme Signed-off-by: Francisco Javier Arceo --- docs/_static/js/detect_theme.js | 9 +++++++++ docs/source/conf.py | 1 + 2 files changed, 10 insertions(+) create mode 100644 docs/_static/js/detect_theme.js diff --git a/docs/_static/js/detect_theme.js b/docs/_static/js/detect_theme.js new file mode 100644 index 000000000..484b2bb8b --- /dev/null +++ b/docs/_static/js/detect_theme.js @@ -0,0 +1,9 @@ +document.addEventListener("DOMContentLoaded", function () { + const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; + const htmlElement = document.documentElement; + if (prefersDark) { + htmlElement.setAttribute("data-theme", "dark"); + } else { + htmlElement.setAttribute("data-theme", "light"); + } +}); diff --git a/docs/source/conf.py b/docs/source/conf.py index da2cf2d28..55c6383b2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -121,6 +121,7 @@ html_static_path = ["../_static"] def setup(app): app.add_css_file("css/my_theme.css") + app.add_js_file("js/detect_theme.js") def dockerhub_role(name, rawtext, text, lineno, inliner, options={}, content=[]): url = f"https://hub.docker.com/r/llamastack/{text}"