Skip to content

Commit 353b31e

Browse files
committed
Add a custom base.html which moves up the JS loading
This was supposed to be added to 17c26d6.
1 parent 96e0633 commit 353b31e

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

docs/source/_templates/base.html

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<!-- Based on https://github.com/pradyunsg/furo/blob/a72186fbfb7f1dc35cb9a46b874cb5e61116b52c/src/furo/theme/furo/base.html -->
2+
<!-- But only moved up the JS -->
3+
<!-- Like done in https://github.com/tradingstrategy-ai/web3-ethereum-defi/blob/master/docs/source/_templates/base.html -->
4+
<!-- Which I figured out via https://github.com/pradyunsg/furo/discussions/456 -->
5+
6+
<!doctype html>
7+
<html class="no-js"{% if language is not none %} lang="{{ language }}"{% endif %}>
8+
<head>
9+
{%- block site_meta -%}
10+
<meta charset="utf-8"/>
11+
<meta name="viewport" content="width=device-width,initial-scale=1"/>
12+
<meta name="color-scheme" content="light dark">
13+
14+
{%- if metatags %}{{ metatags }}{% endif -%}
15+
16+
{%- block linktags %}
17+
{%- if hasdoc('about') -%}
18+
<link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
19+
{%- endif -%}
20+
{%- if hasdoc('genindex') -%}
21+
<link rel="index" title="{{ _('Index') }}" href="{{ pathto('genindex') }}" />
22+
{%- endif -%}
23+
{%- if hasdoc('search') -%}
24+
<link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}" />
25+
{%- endif -%}
26+
{%- if hasdoc('copyright') -%}
27+
<link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}" />
28+
{%- endif -%}
29+
{%- if next -%}
30+
<link rel="next" title="{{ next.title|striptags|e }}" href="{{ next.link|e }}" />
31+
{%- endif -%}
32+
{%- if prev -%}
33+
<link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}" />
34+
{%- endif -%}
35+
{#- rel="canonical" (set by html_baseurl) -#}
36+
{%- if pageurl %}
37+
<link rel="canonical" href="{{ pageurl|e }}" />
38+
{%- endif %}
39+
{%- endblock linktags %}
40+
41+
{# Favicon #}
42+
{%- if favicon_url -%}
43+
<link rel="shortcut icon" href="{{ favicon_url }}"/>
44+
{%- endif -%}
45+
46+
{#- Generator banner -#}
47+
<meta name="generator" content="sphinx-{{ sphinx_version }}, furo {{ furo_version }}"/>
48+
49+
{%- endblock site_meta -%}
50+
51+
{#- Site title -#}
52+
{%- block htmltitle -%}
53+
{% if not docstitle %}
54+
<title>{{ title|striptags|e }}</title>
55+
{% elif pagename == master_doc %}
56+
<title>{{ docstitle|striptags|e }}</title>
57+
{% else %}
58+
<title>{{ title|striptags|e }} - {{ docstitle|striptags|e }}</title>
59+
{% endif %}
60+
{%- endblock -%}
61+
62+
{%- block styles -%}
63+
64+
{# Custom stylesheets #}
65+
{%- block regular_styles -%}
66+
{%- for css in css_files -%}
67+
{% if css|attr("filename") -%}
68+
{{ css_tag(css) }}
69+
{%- else -%}
70+
<link rel="stylesheet" href="{{ pathto(css, 1)|e }}" type="text/css" />
71+
{%- endif %}
72+
{% endfor -%}
73+
{%- endblock regular_styles -%}
74+
75+
{#- Theme-related stylesheets -#}
76+
{%- block theme_styles %}
77+
{% include "partials/_head_css_variables.html" with context %}
78+
{%- endblock -%}
79+
80+
{%- block extra_styles %}
81+
{%- endblock -%}
82+
83+
{%- endblock styles -%}
84+
85+
{#- Custom front matter #}
86+
{%- block extrahead -%}{%- endblock -%}
87+
88+
{# Custom JS #}
89+
{%- block regular_scripts -%}
90+
{% for path in script_files -%}
91+
{{ js_tag(path) }}
92+
{% endfor -%}
93+
{%- endblock regular_scripts -%}
94+
95+
{# Theme-related JavaScript code #}
96+
{%- block theme_scripts -%}
97+
{%- endblock -%}
98+
99+
</head>
100+
<body>
101+
{% block body %}
102+
<script>
103+
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
104+
</script>
105+
{% endblock %}
106+
107+
{%- block scripts -%}
108+
{%- endblock scripts -%}
109+
</body>
110+
</html>

0 commit comments

Comments
 (0)