2024-08-01 18:00:57 +02:00
|
|
|
;;;; -*- mode: common-lisp; coding: utf-8; -*-
|
|
|
|
|
|
|
|
(defpackage ml-sbt/breadcrumb
|
|
|
|
(:use :cl)
|
|
|
|
(:export :with-breadcrumb))
|
|
|
|
|
2024-08-01 21:00:30 +02:00
|
|
|
(in-package :ml-sbt/breadcrumb)
|
|
|
|
|
2024-10-22 16:32:17 +02:00
|
|
|
(defmacro with-breadcrumb (container &rest items)
|
2024-08-01 18:00:57 +02:00
|
|
|
"Creates a Bootstrap breadcrumb navigation.
|
2024-08-03 12:48:42 +02:00
|
|
|
|
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-03 12:48:42 +02:00
|
|
|
|
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-02 07:39:12 +02:00
|
|
|
(let ((items-length (/ (length items) 2)))
|
|
|
|
`(spinneret:with-html
|
2024-10-22 16:32:17 +02:00
|
|
|
(:nav :class ,(concatenate 'string "container-" container)
|
2024-08-02 07:39:12 +02:00
|
|
|
:aria-label "breadcrumb"
|
|
|
|
(:ol :class "breadcrumb"
|
|
|
|
,@(loop for (label url) on items by #'cddr
|
|
|
|
for i from 1
|
|
|
|
collect (if (= i items-length)
|
|
|
|
`(:li :class "breadcrumb-item active" :aria-current "page" ,label)
|
|
|
|
`(:li :class "breadcrumb-item" (:a :href ,url ,label)))))))))
|