Skip to content

Commit 4a14d32

Browse files
creating dinamic tag for breadcrumb
1 parent 7cb06ea commit 4a14d32

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/ui/breadcrumb.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ function itemStyle(item) {
66
style += item.url ? " text-gray-700 hover:text-gray-900" : " text-gray-500";
77
return style;
88
}
9+
10+
items.forEach((item) => {
11+
item.tag = item.url ? "a" : "div";
12+
});
913
---
1014

1115
<nav class="flex" aria-label="Breadcrumb">
1216
<ol class="inline-flex items-center space-x-1 md:space-x-2">
1317
{
1418
items.map((item) => (
1519
<li class="inline-flex items-center">
16-
<a href={item.url} class={itemStyle(item)}>
20+
<item.tag href={item.url} class={itemStyle(item)}>
1721
{item.home ? (
1822
<svg
1923
aria-hidden="true"
@@ -40,7 +44,7 @@ function itemStyle(item) {
4044
</svg>
4145
)}
4246
{item.home ? <span>{item.label}</span> : <span class="md:ml-2">{item.label}</span>}
43-
</a>
47+
</item.tag>
4448
</li>
4549
))
4650
}

0 commit comments

Comments
 (0)