From 2d1b7d8eb50285336f777a3e59d1d11b03bcd37f Mon Sep 17 00:00:00 2001 From: Akira Tempaku <paku@skyizwhite.dev> Date: Thu, 1 May 2025 23:49:52 +0900 Subject: [PATCH] Make current page link inactive in navbar --- src/ui/layout.lisp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ui/layout.lisp b/src/ui/layout.lisp index 94dae2a..ea14831 100644 --- a/src/ui/layout.lisp +++ b/src/ui/layout.lisp @@ -3,12 +3,19 @@ #:hsx) (:import-from #:hp/lib/metadata #:~metadata) + (:import-from #:jingle + #:request-uri) (:export #:~layout)) (in-package #:hp/ui/layout) (defun bust-cache (url) (format nil "~a?v=~a" url #.(get-universal-time))) +(defparameter *nav-menu* + '(("/bio" "bio") + ("/work" "work") + ("/blog" "blog"))) + (defcomp ~layout (&key metadata children) (hsx (html :lang "ja" @@ -46,9 +53,14 @@ (nav :class "flex items-end" (ul :preload "mouseover" - :class "flex gap-4 text-lg [&_a]:underline [&_a]:hover:text-pink-500" - (li (a :href "/bio" "bio")) - (li (a :href "/work" "work")) - (li (a :href "/blog" "blog"))))) + :class "flex gap-4 text-lg" + (loop + :for (href label) :in *nav-menu* + :collect + (if (search href (request-uri jingle:*request*)) + (hsx (li :class "text-pink-500" + label)) + (hsx (li (a :href href :class "underline hover:text-pink-500" + label)))))))) (main :class "flex-1 pt-2 pb-4 md:pt-4 md:pb-8 overflow-y-scroll " children))))))