summary refs log tree commit diff
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2023-05-17 23:48:16 -0500
committerStarfall <us@starfall.systems>2023-05-24 12:51:23 -0500
commit1df389da097411e437aa33aa104132bc593e1ed4 (patch)
tree73436a20e5431f8a993c0ab700b21da52e9290ec
parent59b4b8a05c0db82ffec953f0e2e6e484c6e74b45 (diff)
feature: use eleventyNavigation plugin for nav
-rw-r--r--_includes/base.njk10
-rw-r--r--eleventy.config.js6
-rw-r--r--package-lock.json23
-rw-r--r--package.json1
-rw-r--r--src/blog.njk5
-rw-r--r--src/git-link.md8
-rw-r--r--src/index.html1
7 files changed, 49 insertions, 5 deletions
diff --git a/_includes/base.njk b/_includes/base.njk
index c3602c7..6ff7553 100644
--- a/_includes/base.njk
+++ b/_includes/base.njk
@@ -2,7 +2,7 @@
 title = "Starfall"
 ---
 <!doctype html>
-<html lang=en._US dir=ltr>
+<html lang=en-US dir=ltr>
 <title>{{ title }}</title>
 <meta charset=UTF-8>
 <meta name=robots content="noindex, nofollow">
@@ -13,9 +13,11 @@ title = "Starfall"
 <header>
 	<h1>{{ title }}</h1>
 	<nav aria-label=primary>
-		<ul>
-			<li><a href=/ class=active aria-current=page>Home</a>
-			<li><a href=https://git.starfall.systems>Git</a>
+		{% set navs = collections.all | eleventyNavigation %}
+		<ul>{%- for nav in navs %}
+			<li>
+				<a href="{{ nav.url }}"{% if nav.url == page.url %} class="active" aria-current="page"{% endif %}>{{ nav.title }}</a>
+			</li>{%- endfor %}
 		</ul>
 	</nav>
 </header>
diff --git a/eleventy.config.js b/eleventy.config.js
index 05a4db3..36722b2 100644
--- a/eleventy.config.js
+++ b/eleventy.config.js
@@ -1,3 +1,6 @@
+const toml = require('@iarna/toml')
+const eleventyNavigation = require('@11ty/eleventy-navigation')
+
 filter_local_date = function(date) {
 	// yyyy-MM-dd
 	return date.getFullYear() + '-'
@@ -11,9 +14,10 @@ filter_rfc3339_datetime = function(date) {
 	return date.toISOString().replace('T', ' ');
 }
 
-const toml = require('@iarna/toml')
 
 module.exports = function(eleventyConfig) {
+	eleventyConfig.addPlugin(eleventyNavigation)
+
 	eleventyConfig.addPassthroughCopy('./css/')
 
 	eleventyConfig.addFilter('local_date', filter_local_date)
diff --git a/package-lock.json b/package-lock.json
index 6b22009..32621d8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,6 +9,7 @@
 			"license": "UNLICENSED",
 			"devDependencies": {
 				"@11ty/eleventy": "^2.0.1",
+				"@11ty/eleventy-navigation": "^0.3.5",
 				"@iarna/toml": "^3.0.0"
 			}
 		},
@@ -103,6 +104,19 @@
 				"url": "https://opencollective.com/11ty"
 			}
 		},
+		"node_modules/@11ty/eleventy-navigation": {
+			"version": "0.3.5",
+			"resolved": "https://registry.npmjs.org/@11ty/eleventy-navigation/-/eleventy-navigation-0.3.5.tgz",
+			"integrity": "sha512-4aKW5aIQDFed8xs1G1pWcEiFPcDSwZtA4IH1eERtoJ+Xy+/fsoe0pzbDmw84bHZ9ACny5jblENhfZhcCxklqQw==",
+			"dev": true,
+			"dependencies": {
+				"dependency-graph": "^0.11.0"
+			},
+			"funding": {
+				"type": "opencollective",
+				"url": "https://opencollective.com/11ty"
+			}
+		},
 		"node_modules/@11ty/eleventy-utils": {
 			"version": "1.0.1",
 			"resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-1.0.1.tgz",
@@ -2430,6 +2444,15 @@
 				"ws": "^8.13.0"
 			}
 		},
+		"@11ty/eleventy-navigation": {
+			"version": "0.3.5",
+			"resolved": "https://registry.npmjs.org/@11ty/eleventy-navigation/-/eleventy-navigation-0.3.5.tgz",
+			"integrity": "sha512-4aKW5aIQDFed8xs1G1pWcEiFPcDSwZtA4IH1eERtoJ+Xy+/fsoe0pzbDmw84bHZ9ACny5jblENhfZhcCxklqQw==",
+			"dev": true,
+			"requires": {
+				"dependency-graph": "^0.11.0"
+			}
+		},
 		"@11ty/eleventy-utils": {
 			"version": "1.0.1",
 			"resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-1.0.1.tgz",
diff --git a/package.json b/package.json
index 9abdcdd..efdc36e 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
 	},
 	"devDependencies": {
 		"@11ty/eleventy": "^2.0.1",
+		"@11ty/eleventy-navigation": "^0.3.5",
 		"@iarna/toml": "^3.0.0"
 	}
 }
diff --git a/src/blog.njk b/src/blog.njk
index 84c6f03..4d8dfab 100644
--- a/src/blog.njk
+++ b/src/blog.njk
@@ -1,10 +1,15 @@
 ---
 layout = "base.njk"
+
 [pagination]
 data = "collections.post"
 alias = "posts"
 size = 20
 reverse = true
+
+[eleventyNavigation]
+key = "Blog"
+order = 1
 ---
 {% for post in posts %}
 <article class=blogpost>
diff --git a/src/git-link.md b/src/git-link.md
new file mode 100644
index 0000000..29d327d
--- /dev/null
+++ b/src/git-link.md
@@ -0,0 +1,8 @@
+---
+permalink = false
+
+[eleventyNavigation]
+key = "Git"
+url = "https://git.starfall.systems"
+order = 2
+---
diff --git a/src/index.html b/src/index.html
index 1af2fb6..8cef046 100644
--- a/src/index.html
+++ b/src/index.html
@@ -1,6 +1,7 @@
 ---
 title = "starfall.systems"
 layout = "base.njk"
+eleventyNavigation.key = "Home"
 ---
 
 Hello, World!