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 33654fe67..55c6383b2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -112,6 +112,8 @@ html_theme_options = { # "style_nav_header_background": "#c3c9d4", } +default_dark_mode = False + html_static_path = ["../_static"] # html_logo = "../_static/llama-stack-logo.png" # html_style = "../_static/css/my_theme.css" @@ -119,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}"