Link docs /latest/ to /stable/ again

Re-implementing the pattern from https://til.simonwillison.net/readthedocs/link-from-latest-to-stable

Refs #1608
pull/2046/head
Simon Willison 2023-03-26 16:23:28 -07:00 zatwierdzone przez GitHub
rodzic 3feed1f66e
commit 5c1cfa451d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 25 dodań i 0 usunięć

Wyświetl plik

@ -3,4 +3,29 @@
{% block site_meta %}
{{ super() }}
<script defer data-domain="docs.datasette.io" src="https://plausible.io/js/plausible.js"></script>
<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);
$("article[role=main]").prepend(warning);
}
});
});
</script>
{% endblock %}