File size: 1,081 Bytes
e48ff6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)