auto populate nav and footer
This commit is contained in:
@ -15,6 +15,10 @@
|
||||
<meta property="og:description" content="Solstice Market at the Beall Greenhouses" />
|
||||
<meta property="og:image" content="/img/logo-light.png" />
|
||||
<meta property="og:image:alt" content="Linework icon depicting a sunrise or sunset with two clouds, in a blue and orange color scheme" />
|
||||
|
||||
<!-- JS -->
|
||||
<script src="/scripts/nav.js" defer></script>
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="/styles/main.css">
|
||||
<link rel="stylesheet" href="/styles/nav.css">
|
||||
@ -23,10 +27,7 @@
|
||||
<body>
|
||||
<div id="content">
|
||||
<header>
|
||||
<nav>
|
||||
<a href="/">↩ back home</a>
|
||||
<a href="/directory">🧺 all markets</a>
|
||||
</nav>
|
||||
<nav id="top-nav"><!-- auto-populated by nav.js --></nav>
|
||||
|
||||
<img id="logo-dark" src="/img/logo-dark.png" alt="Linework icon depicting a sunrise or sunset with two clouds, in a blue and orange color scheme">
|
||||
<img id="logo-light" src="/img/logo-light.png" alt="Linework icon depicting a sunrise or sunset with two clouds, in a blue and orange color scheme">
|
||||
@ -122,21 +123,6 @@
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<footer>
|
||||
<div id="contacts">
|
||||
<p>
|
||||
Website questions or feedback?
|
||||
<a href="mailto:lee.cattarin@gmail.com?cc=montanahawke@gmail.com&subject=Beall%20Greenhouses%20Market">
|
||||
email Lee
|
||||
</a>
|
||||
</p>
|
||||
<p>Market questions?
|
||||
<a href="mailto:montanahawke@gmail.com?subject=Beall%20Greenhouses%20Market">
|
||||
email Hawke
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<p>brought to you in 2025</p>
|
||||
</footer>
|
||||
<footer id="footer"><!-- auto-populated by nav.js --></footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
<meta property="og:description" content="Directory | Markets at the Beall Greenhouses" />
|
||||
<meta property="og:image" content="/img/logo-light.png" />
|
||||
<meta property="og:image:alt" content="Linework icon depicting a sunrise or sunset with two clouds, in a blue and orange color scheme" />
|
||||
|
||||
<!-- JS -->
|
||||
<script src="/scripts/nav.js" defer></script>
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="/styles/main.css">
|
||||
<link rel="stylesheet" href="/styles/nav.css">
|
||||
@ -24,10 +28,7 @@
|
||||
<body>
|
||||
<div id="content">
|
||||
<header>
|
||||
<nav>
|
||||
<a href="/">↩ back home</a>
|
||||
<a id="current-page" href="/directory">🧺 all markets</a>
|
||||
</nav>
|
||||
<nav id="top-nav"><!-- auto-populated by nav.js --></nav>
|
||||
|
||||
<img id="logo-dark" src="/img/logo-dark.png" alt="Linework icon depicting a sunrise or sunset with two clouds, in a blue and orange color scheme">
|
||||
<img id="logo-light" src="/img/logo-light.png" alt="Linework icon depicting a sunrise or sunset with two clouds, in a blue and orange color scheme">
|
||||
@ -46,21 +47,6 @@
|
||||
|
||||
</main>
|
||||
</div>
|
||||
<footer>
|
||||
<div id="contacts">
|
||||
<p>
|
||||
Website questions or feedback?
|
||||
<a href="mailto:lee.cattarin@gmail.com?cc=montanahawke@gmail.com&subject=Beall%20Greenhouses%20Market">
|
||||
email Lee
|
||||
</a>
|
||||
</p>
|
||||
<p>Market questions?
|
||||
<a href="mailto:montanahawke@gmail.com?subject=Beall%20Greenhouses%20Market">
|
||||
email Hawke
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<p>brought to you in 2026</p>
|
||||
</footer>
|
||||
<footer id="footer"><!-- auto-populated by nav.js --></footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
25
index.html
25
index.html
@ -15,6 +15,10 @@
|
||||
<meta property="og:description" content="Markets at the Beall Greenhouses" />
|
||||
<meta property="og:image" content="/img/logo-light.png" />
|
||||
<meta property="og:image:alt" content="Linework icon depicting a sunrise or sunset with two clouds, in a blue and orange color scheme" />
|
||||
|
||||
<!-- JS -->
|
||||
<script src="/scripts/nav.js" defer></script>
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="/styles/main.css">
|
||||
<link rel="stylesheet" href="/styles/nav.css">
|
||||
@ -23,9 +27,7 @@
|
||||
<body>
|
||||
<div id="content">
|
||||
<header>
|
||||
<nav>
|
||||
<a id="current-page" href="/">↩ back home</a>
|
||||
<a href="/directory">🧺 all markets</a>
|
||||
<nav id="top-nav">
|
||||
</nav>
|
||||
|
||||
<img id="logo-dark" src="/img/logo-dark.png" alt="Linework icon depicting a sunrise or sunset with two clouds, in a blue and orange color scheme">
|
||||
@ -38,21 +40,6 @@
|
||||
<p>We've just completed a successful <a href="/2025/solstice">Solstice 2025</a> market. Stay tuned for more!</p>
|
||||
</main>
|
||||
</div>
|
||||
<footer>
|
||||
<div id="contacts">
|
||||
<p>
|
||||
Website questions or feedback?
|
||||
<a href="mailto:lee.cattarin@gmail.com?cc=montanahawke@gmail.com&subject=Beall%20Greenhouses%20Market">
|
||||
email Lee
|
||||
</a>
|
||||
</p>
|
||||
<p>Market questions?
|
||||
<a href="mailto:montanahawke@gmail.com?subject=Beall%20Greenhouses%20Market">
|
||||
email Hawke
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<p>brought to you in 2026</p>
|
||||
</footer>
|
||||
<footer id="footer"><!-- auto-populated by nav.js --></footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
54
scripts/nav.js
Normal file
54
scripts/nav.js
Normal file
@ -0,0 +1,54 @@
|
||||
/* Top nav */
|
||||
const navItems = [
|
||||
{
|
||||
href: "/",
|
||||
name: "↩ back home"
|
||||
},
|
||||
{
|
||||
href: "/directory/",
|
||||
name: "🧺 all markets"
|
||||
}
|
||||
];
|
||||
|
||||
const populateNav = function() {
|
||||
let nav = document.getElementById("top-nav");
|
||||
let path = window.location.pathname;
|
||||
console.log(path);
|
||||
|
||||
for (const item of navItems) {
|
||||
let a = document.createElement("a");
|
||||
a.href = item.href;
|
||||
a.innerHTML = item.name;
|
||||
|
||||
if (item.href === path) a.id = "current-page";
|
||||
|
||||
nav.append(a);
|
||||
}
|
||||
}
|
||||
|
||||
populateNav();
|
||||
|
||||
/* Footer */
|
||||
const footerHTML = `
|
||||
<div id="contacts">
|
||||
<p>
|
||||
Website questions or feedback?
|
||||
<a href="mailto:lee.cattarin@gmail.com?cc=montanahawke@gmail.com&subject=Beall%20Greenhouses%20Market">
|
||||
email Lee
|
||||
</a>
|
||||
</p>
|
||||
<p>Market questions?
|
||||
<a href="mailto:montanahawke@gmail.com?subject=Beall%20Greenhouses%20Market">
|
||||
email Hawke
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<p>brought to you in 2025</p>
|
||||
`
|
||||
|
||||
const populateFooter = function() {
|
||||
let footer = document.getElementById("footer");
|
||||
footer.innerHTML = footerHTML;
|
||||
}
|
||||
|
||||
populateFooter();
|
||||
Reference in New Issue
Block a user