Added Navigation and This Page
This adds a navigation bar, shows the pattern for front matter that adds pages to the navigation bar. This is also where I crated a How To page (no point in having a navigation bar until I had two pages).
- In
/srcaddedhowto.mdand copied/pasted my notes.[1] - Installed the Eleventy Navigation Plugin with
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");. - In
.eleventy.jsadded `` abovemodule.exportsand added the plugin abovereturn:
// Plugins
eleventyConfig.addPlugin(eleventyNavigationPlugin);
- In
/partials, madenavbar.htmland added code:[2]
<nav>{{ collections.all | eleventyNavigation | eleventyNavigationToHtml({ activeKey: eleventyNavigation.key, useAriaCurrentAttr: true }) | safe }}</nav>.
- In
index.mdfront matter, added:
eleventyNavigation:
key: Home
order: 1
- In
howto.mdfront matter, added:[3]
eleventyNavigation:
key: How To
order: 2
Footnotes
- As I built this website, I took notes about what I was doing in Drafts, an app I love very much! ↩
-
This collects the EleventyNavigation keys and URLs (we are about to make those), and adds a function to correctly set
aria-current="page". Putting all of that in<nav></nav>makes everything display correctly. ↩ - This pattern will repeat in all new pages except for blog entries. ↩