saudade/menu.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

(async () => {
2023-12-10 20:37:03 -08:00
// menu style
const menuStyle = document.createElement("link");
menuStyle.rel = "stylesheet";
menuStyle.href = "/style/menu.css";
document.head.append(menuStyle);
2023-06-10 15:01:28 -07:00
2023-12-10 20:37:03 -08:00
// build menu
const siteRoot = "/" + location.pathname.split("/")[1];
const { wayback } = await import(`${siteRoot}/config.js`);
2023-12-10 20:37:03 -08:00
let menu = document.createElement("div");
menu.id = "archive-menu";
2023-12-10 20:37:03 -08:00
let span = document.createElement("span");
span.id = "hrt";
span.innerText = "♥";
menu.append(span);
2023-12-10 20:37:03 -08:00
let archiveRoot = document.createElement("a");
archiveRoot.setAttribute("href", "/");
archiveRoot.setAttribute("target", "_top");
archiveRoot.innerText = "Home";
menu.append(archiveRoot);
2023-12-10 20:37:03 -08:00
let changelog = document.createElement("a");
changelog.setAttribute("href", `${siteRoot}/CHANGELOG.txt`);
changelog.setAttribute("target", "_blank");
changelog.innerText = "Changelog";
menu.append(changelog);
2023-12-10 20:37:03 -08:00
if (wayback) {
let waybackLink = document.createElement("a");
waybackLink.setAttribute("href", `https://web.archive.org/web/${wayback}`);
waybackLink.setAttribute("target", "_blank");
waybackLink.innerText = "Wayback Capture";
menu.append(waybackLink);
}
2023-12-10 20:37:03 -08:00
document.body.prepend(menu);
})();