From 32a98378d504af05408caaad82e414f50dba3ecb Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 3 Sep 2026 00:59:18 -0700 Subject: [PATCH] Highlight current page link in the nav bar --- src/templates/page.rs | 4 ++++ static/page.css | 4 ++++ static/page.js | 3 +++ templates/page.html | 1 + 4 files changed, 12 insertions(+) create mode 100644 static/page.js diff --git a/src/templates/page.rs b/src/templates/page.rs index ecc4e435..72b8e5ee 100644 --- a/src/templates/page.rs +++ b/src/templates/page.rs @@ -101,6 +101,7 @@ mod tests { +
@@ -142,6 +143,7 @@ mod tests { +
@@ -175,6 +177,7 @@ mod tests { +
@@ -210,6 +213,7 @@ mod tests { + diff --git a/static/page.css b/static/page.css index 88dae4b8..ccb88b1f 100644 --- a/static/page.css +++ b/static/page.css @@ -210,6 +210,10 @@ body > header > nav { } a:hover { + text-decoration: underline; + } + + a[aria-current=page] { color: white; } diff --git a/static/page.js b/static/page.js new file mode 100644 index 00000000..a19a546c --- /dev/null +++ b/static/page.js @@ -0,0 +1,3 @@ +document + .querySelector(`nav a[href="${location.pathname}"]`) + ?.setAttribute('aria-current', 'page'); diff --git a/templates/page.html b/templates/page.html index bed1ad4f..3b84f933 100644 --- a/templates/page.html +++ b/templates/page.html @@ -30,6 +30,7 @@ %% if let Some(up) = self.content.up() { %% } + %% if let Some(script) = self.content.script() { %% }