mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
Custom layout template for docs
Adds plausible analytics, closes #389 Implements banner on latest page, closes #388
This commit is contained in:
parent
b3efb29212
commit
89c01103ec
1 changed files with 39 additions and 0 deletions
39
docs/_templates/layout.html
vendored
Normal file
39
docs/_templates/layout.html
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{%- extends "!layout.html" %}
|
||||
|
||||
{% block htmltitle %}
|
||||
{{ super() }}
|
||||
<script defer data-domain="docs.datasette.io" src="https://plausible.io/js/plausible.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block footer %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
jQuery(function ($) {
|
||||
// Show banner linking to /stable/ if this is a /latest/ page
|
||||
if (!/\/latest\//.test(location.pathname)) {
|
||||
return;
|
||||
}
|
||||
var stableUrl = location.pathname.replace("/latest/", "/stable/");
|
||||
// Check it's not a 404
|
||||
fetch(stableUrl, { method: "HEAD" }).then((response) => {
|
||||
if (response.status == 200) {
|
||||
var warning = $(
|
||||
`<div class="admonition warning">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p class="last">
|
||||
This documentation covers the <strong>development version</strong> of <code>sqlite-utils</code>.</p>
|
||||
<p>See <a href="${stableUrl}">this page</a> for the current stable release.
|
||||
</p>
|
||||
</div>`
|
||||
);
|
||||
warning.find("a").attr("href", stableUrl);
|
||||
var body = $("div.body");
|
||||
if (!body.length) {
|
||||
body = $("div.document");
|
||||
}
|
||||
body.prepend(warning);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue