File tree Expand file tree Collapse file tree 1 file changed +61
-0
lines changed
Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ import Icon from ' @/components/Icon.astro'
3+
4+ interface BreadcrumbItem {
5+ icon: string
6+ title: string
7+ url: string
8+ }
9+
10+ interface Props {
11+ items: BreadcrumbItem []
12+ }
13+
14+ const { items } = Astro .props
15+ const hasIcon = (item : BreadcrumbItem ) => item .icon .length > 0
16+ ---
17+ <ul role =" list" class =" breadcrumb" >
18+ <li class =" pr-1" >
19+ <a href =" /" class =" breadcrumb-item" >
20+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 16" height =" 16" fill =" currentColor" class =" bi bi-house-heart" viewBox =" 0 0 16 16" >
21+ <path d =" M8 6.982C9.664 5.309 13.825 8.236 8 12 2.175 8.236 6.336 5.309 8 6.982Z" />
22+ <path d =" M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.707L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.646a.5.5 0 0 0 .708-.707L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.707 1.5ZM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5 5 5Z" />
23+ </svg >
24+ <span class =" pl-1" >Home</span >
25+ </a >
26+ </li >
27+ { items .map ((item ) =>
28+ <>
29+ <li >/</li >
30+ <li >
31+ {
32+ item .url .length === 0
33+ ?
34+ <div class = " breadcrumb-item" >
35+ { hasIcon (item ) && <Icon name = { item .icon } /> }
36+ <span class = " pl-1" >{ item .title } </span >
37+ </div >
38+ :
39+ <a href = { item .url } class = " breadcrumb-item" >
40+ { hasIcon (item ) && <Icon name = { item .icon } /> }
41+ <span class = " pl-1" >{ item .title } </span >
42+ </a >
43+ }
44+ </li >
45+ </>
46+ )}
47+ </ul >
48+ <style is:global >
49+ .breadcrumb {
50+ @apply inline-flex mb-3;
51+ @apply list-none pl-0 !important;
52+ }
53+
54+ .breadcrumb .breadcrumb-item {
55+ @apply inline-flex items-center my-0 font-semibold;
56+ }
57+
58+ .breadcrumb li:not(:first-child) {
59+ @apply text-style-primary;
60+ }
61+ </style >
You can’t perform that action at this time.
0 commit comments