Files
beall-greenhouses/assets/scripts/nav.js

92 lines
2.0 KiB
JavaScript
Raw Normal View History

2025-12-28 12:41:27 -08:00
/* Top nav */
const navItems = [
2025-12-29 09:10:28 -08:00
{
href: "/about/",
2026-01-02 09:36:44 -08:00
title: "ⓘ about",
tooltip: "about the Beall Greenhouses"
2025-12-28 12:41:27 -08:00
},
{
2025-12-29 08:44:57 -08:00
href: "/events/",
2026-01-02 09:36:44 -08:00
title: "🗓 events",
tooltip: "events at the Beall Greenhouses"
},
{
href: "/artists/",
title: "🖌 artists",
tooltip: "artists in residence at the Beall Greenhouses"
2025-12-28 12:41:27 -08:00
}
];
2026-01-02 09:36:44 -08:00
const createMenuLink = function(title, href, tooltip) {
let path = window.location.pathname;
let a = document.createElement("a");
a.href = href;
a.innerHTML = title;
a.title = tooltip;
a.ariaLabel = tooltip;
2026-01-06 15:15:23 -08:00
if (href === "#main") a.id = "skip";
else if (href === path) a.id = "current-page";
2026-01-02 09:36:44 -08:00
return a;
}
2026-01-06 15:15:23 -08:00
const createHomeLink = function() {
let path = window.location.pathname;
let a = document.createElement("a");
a.href = "/";
a.ariaLabel = "Beall Greenhouses home";
if (path === "/") {
a.id = "current-page";
a.title = "Beall Greenhouses home";
} else {
a.title = "↩ Beall Greenhouses home"
}
let logo = document.createElement("img");
logo.src = "/assets/img/logo.jpg";
logo.alt = "block print in black and orange of a rufous hummingbird in flight with tail flared. the hummingbird holds a banner that reads 'become ungovernable.'"
a.append(logo);
2026-01-02 09:36:44 -08:00
return a;
}
2026-01-06 15:15:23 -08:00
const createNav = function() {
let nav = document.createElement("nav");
2025-12-28 12:41:27 -08:00
2026-01-06 15:15:23 -08:00
nav.append(createMenuLink("skip ↷", "#main", "skip to main content"));
nav.append(createHomeLink());
2026-01-06 21:45:32 -08:00
2025-12-29 09:29:40 -08:00
let ul = document.createElement("ul");
2025-12-28 12:41:27 -08:00
for (const item of navItems) {
2025-12-29 09:29:40 -08:00
let li = document.createElement("li");
2026-01-02 09:36:44 -08:00
li.append(createMenuLink(item.title, item.href, item.tooltip));
2025-12-29 09:29:40 -08:00
ul.append(li);
2025-12-28 12:41:27 -08:00
}
nav.append(ul);
2026-01-06 15:15:23 -08:00
return nav;
2025-12-28 12:41:27 -08:00
}
2026-01-06 15:15:23 -08:00
let header = document.querySelector("header");
header.append(createNav());
2025-12-28 12:41:27 -08:00
/* Footer */
const footerHTML = `
2026-01-02 16:32:03 -08:00
<p>questions?
<a href="mailto:beall.greenhouses@gmail.com">email us!</a>
</p>
2025-12-29 09:12:47 -08:00
<p>brought to you in 2026</p>
2025-12-28 12:41:27 -08:00
`
const populateFooter = function() {
let footer = document.getElementById("footer");
footer.innerHTML = footerHTML;
}
populateFooter();