// @ts-check
require("bootstrap");
function initDownloadButton() {
const buttons = $(".download-btn");
if (buttons.length <= 0) {
return;
}
$.ajax({
method: "GET",
url: "https://api.github.com/repos/lektor/lektor/releases",
crossDomain: true,
}).then((releases) => {
updateDownloadButtons(buttons.toArray(), releases);
});
}
function updateDownloadButtons(buttons, releases) {
let tag = releases[0].tag_name;
buttons.forEach((button) => {
let link = $("a", button);
link.attr("href", "/downloads/");
link.append($('').text(tag));
});
}
function initGoogleSearch() {
var container = $(".google-custom-search");
if (container.length == 0) {
return;
}
var cx = "012722186170730423054:utwznhnrrmi";
var gcse = document.createElement("script");
gcse.type = "text/javascript";
gcse.async = true;
gcse.src =
(document.location.protocol == "https:" ? "https:" : "http:") +
"//cse.google.com/cse.js?cx=" +
cx;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gcse, s);
$(`