2024-08-01 18:00:57 +02:00
|
|
|
;;;; -*- mode: common-lisp; coding: utf-8; -*-
|
|
|
|
|
|
|
|
(defpackage ml-sbt/breadcrumb
|
|
|
|
(:use :cl)
|
|
|
|
(:export :with-breadcrumb))
|
|
|
|
|
|
|
|
(defmacro with-breadcrumb (&rest items)
|
|
|
|
"Creates a Bootstrap breadcrumb navigation.
|
|
|
|
|
2024-08-01 20:54:52 +02:00
|
|
|
ITEMS: A list of \"label\" \"url\" pairs. The last item is automatically set as active.
|
2024-08-01 18:00:57 +02:00
|
|
|
|
|
|
|
Example usage:
|
|
|
|
(with-breadcrumb
|
2024-08-01 20:54:52 +02:00
|
|
|
\"Home\" \"/\"
|
|
|
|
\"Library\" \"/library\"
|
|
|
|
\"Data\" nil)"
|
2024-08-01 18:00:57 +02:00
|
|
|
`(spinneret:with-html
|
|
|
|
(:nav :class "container"
|
|
|
|
:aria-label "breadcrumb"
|
|
|
|
(:ol :class "breadcrumb"
|
|
|
|
,@(loop for (label url) on items by #'cddr
|
|
|
|
for last-p = (null (cdr items))
|
|
|
|
collect (if last-p
|
|
|
|
`(:li :class "breadcrumb-item active" :aria-current "page" ,label)
|
|
|
|
`(:li :class "breadcrumb-item" (:a :href ,url ,label))))))))
|