From 17f2516c3cf081c4e22eba5a9d694954784dcf17 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 11 Apr 2021 11:05:45 +0200 Subject: website: Disable menu item for current location. --- haunt.scm | 43 +++++++++++++++++++++++++------------------ software.md | 1 + static/css/main.css | 4 +++- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/haunt.scm b/haunt.scm index 5d00630..54090b7 100644 --- a/haunt.scm +++ b/haunt.scm @@ -22,7 +22,8 @@ (haunt builder assets) (haunt reader) (haunt reader commonmark) - (srfi srfi-71)) + (srfi srfi-71) + (ice-9 match)) (define %cwd (and=> (assq-ref (current-source-location) 'filename) @@ -39,19 +40,25 @@ (define* (base-layout body #:key (title "") (meta '()) (posts '()) site) - (define menubar - `(div (@ (id "menubar") - (class "width-control")) - (ul - (li (a (@ (href ,(base-url "/"))) - "About")) - (li (a (@ (href ,(base-url "/software"))) - "Software")) - (li (a (@ (href ,(base-url "/blog"))) - "Blog")) - (li (a (@ (href ,(base-url "/blog/feed.xml"))) - (img (@ (alt "Atom feed") - (src ,(image-url "/feed.png"))))))))) + (define (menubar where) + (let ((locations + '(("about" "About" "/") + ("software" "Software" "/software") + ("blog" "Blog" "/blog")))) + `(div (@ (id "menubar") + (class "width-control")) + (ul + ,@(map (match-lambda + ((key text path) + (if (and where (string=? where key)) + `(li (@ (class "selected")) + (span ,text)) + `(li (a (@ (href ,(base-url path))) + ,text))))) + locations) + (li (a (@ (href ,(base-url "/blog/feed.xml"))) + (img (@ (alt "Atom feed") + (src ,(image-url "/feed.png")))))))))) (define front-page? (assoc-ref meta 'frontpage)) @@ -85,7 +92,7 @@ ;; Add the large-font welcoming message on the ;; front page. - ,@(if (assoc-ref meta 'frontpage) + ,@(if front-page? `((p (@ (id "heading") (class "front-page-heading")) "Welcome to the GNU Assembly! We write " @@ -95,9 +102,9 @@ "giving them individual and collective control " "over their computing, from the operating " "system to applications.")) - `(,menubar)))) - ,@(if (assoc-ref meta 'frontpage) - `(,menubar) + `(,(menubar (assoc-ref meta 'menu)))))) + ,@(if front-page? + `(,(menubar "about")) '()) (div (@ (id "content") diff --git a/software.md b/software.md index af4b017..5e5c455 100644 --- a/software.md +++ b/software.md @@ -1,5 +1,6 @@ title: Participating Projects author: The GNU Assembly +menu: software --- # Participating Projects diff --git a/static/css/main.css b/static/css/main.css index e11cfb1..8e2d1a0 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -225,7 +225,9 @@ hr { text-decoration: none; font-size: small; } - +#menubar li.selected span { + border-bottom: 2px solid black; +} #menubar li img { vertical-align: middle; } -- cgit v1.2.1