mirror of https://github.com/pyodide/pyodide.git
DOC Switch to Plausible analytics in the docs (#3004)
This commit is contained in:
parent
f864eee8b5
commit
4cdc054cb7
|
@ -0,0 +1,7 @@
|
|||
{% extends '!layout.html' %} {%- block extrahead %} {{ super() }}
|
||||
<script
|
||||
defer
|
||||
data-domain="pyodide.org"
|
||||
src="https://plausible.io/js/plausible.js"
|
||||
></script>
|
||||
{%- endblock %}
|
15
docs/conf.py
15
docs/conf.py
|
@ -146,6 +146,21 @@ if IN_READTHEDOCS:
|
|||
encoding="utf-8",
|
||||
)
|
||||
print(res)
|
||||
# insert the Plausible analytics script to console.html
|
||||
console_path = Path("_build/html/console.html")
|
||||
console_html = console_path.read_text().splitlines(keepends=True)
|
||||
for idx, line in enumerate(list(console_html)):
|
||||
if 'pyodide.js">' in line:
|
||||
# insert the analytics script after the `pyodide.js` script
|
||||
console_html.insert(
|
||||
idx,
|
||||
'<script defer data-domain="pyodide.org" src="https://plausible.io/js/plausible.js"></script>\n',
|
||||
)
|
||||
break
|
||||
else:
|
||||
raise ValueError("Could not find pyodide.js in the <head> section")
|
||||
console_path.write_text("".join(console_html))
|
||||
|
||||
|
||||
if IN_SPHINX:
|
||||
# Compatibility shims. sphinx-js and sphinxcontrib-napoleon have not been updated for Python 3.10
|
||||
|
|
Loading…
Reference in New Issue