Show link to /stable/ on /latest/ pages, refs #1608

pull/1610/head
Simon Willison 2022-01-20 14:40:44 -08:00
rodzic 150967d98e
commit ffca55dfd7
1 zmienionych plików z 33 dodań i 0 usunięć

Wyświetl plik

@ -26,3 +26,36 @@
{% include "searchbox.html" %}
{% 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 Datasette.</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 %}