Spaces:
Running
Running
import dash_mantine_components as dmc | |
from components.sidebar import nav_structure | |
def create_breadcrumb(pathname): | |
if pathname == "/": | |
return None | |
items = [{"title": "Accueil", "href": "/"}] | |
found = False | |
for category, content in nav_structure.items(): | |
for link in content["links"]: | |
if link["href"] == pathname: | |
items.append({"title": content["label"], "href": "#"}) | |
items.append({"title": link["label"], "href": pathname}) | |
found = True | |
break | |
if found: | |
break | |
if not found: | |
return None | |
children = [] | |
for i, item in enumerate(items): | |
if i < len(items) - 1: | |
children.append(dmc.Anchor(item["title"], href=item["href"], size="sm")) | |
else: | |
children.append(dmc.Text(item["title"], size="sm")) | |
breadcrumbs = dmc.Breadcrumbs(children=children, separator="→", my="xs") | |
return dmc.Container(fluid=True, px="lg", children=breadcrumbs) |