mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Draft: porting over https://github.com/just-the-docs/just-the-docs/pull/1086/
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
Results in: HTML for the head element.
|
||||
Includes:
|
||||
head_nav.html, head_custom.html.
|
||||
Overwrites:
|
||||
Overwrites:
|
||||
ga_tracking_ids, ga_property, file, favicon.
|
||||
Should not be cached, because included files depend on page.
|
||||
{%- endcomment -%}
|
||||
@@ -14,8 +14,49 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
||||
|
||||
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-default.css' | relative_url }}">
|
||||
|
||||
{% if site.color_scheme_options and site.color_scheme_options.enable_localstorage %}
|
||||
<script>
|
||||
(function(){
|
||||
function createThemeStylesheet(theme, media) {
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = "{{ '/assets/css/just-the-docs-*.css' | relative_url }}".replace("*",theme);
|
||||
if(media) link.media = media;
|
||||
return link;
|
||||
}
|
||||
|
||||
var theme = window.localStorage.getItem('theme');
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
|
||||
if (theme === null) {
|
||||
theme = "{{ site.color_scheme }}";
|
||||
}
|
||||
|
||||
if (theme === "nil") {
|
||||
theme = "default";
|
||||
}
|
||||
|
||||
if (theme === "auto") {
|
||||
head.appendChild(createThemeStylesheet('light', '(prefers-color-scheme: light)'));
|
||||
head.appendChild(createThemeStylesheet('dark', '(prefers-color-scheme: dark)'));
|
||||
} else {
|
||||
head.appendChild(createThemeStylesheet(theme || "default"));
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{% else %}
|
||||
{% case site.color_scheme %}
|
||||
{% when "auto" %}
|
||||
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-light.css' | relative_url }}" type="text/css" media="(prefers-color-scheme: light)">
|
||||
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-dark.css' | relative_url }}" type="text/css" media="(prefers-color-scheme: dark)">
|
||||
{% when nil %}
|
||||
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-default.css' | relative_url }}" type="text/css">
|
||||
{% else %}
|
||||
<link rel="stylesheet" href="{{ site.color_scheme | prepend: '/assets/css/just-the-docs-' | append: '.css' | relative_url }}" type="text/css">
|
||||
{% endcase %}
|
||||
{% endif %}
|
||||
|
||||
{% include head_nav.html %}
|
||||
|
||||
{% if site.ga_tracking != nil %}
|
||||
|
Reference in New Issue
Block a user