Skip to content

Commit a2fd98c

Browse files
committed
Breadcrumbs component edits
1 parent 612c8cd commit a2fd98c

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

src/lib/components/layout/Breadcrumbs.svelte

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
collapseOnMobile = false,
2727
inverse = false,
2828
ariaLabel = "Breadcrumb",
29+
formatBreadcrumbText,
2930
} = $props<{
3031
items?: BreadcrumbItem[];
3132
collapseOnMobile?: boolean;
3233
inverse?: boolean;
3334
ariaLabel?: string;
35+
formatBreadcrumbText?: (text: string[]) => string;
3436
}>();
3537
3638
// Load all page modules for route detection
@@ -53,7 +55,7 @@
5355
5456
// Effect to update breadcrumb items when dependencies change
5557
$effect(() => {
56-
breadcrumbItems = items || generateBreadcrumbItems(page, routeModules);
58+
breadcrumbItems = generateBreadcrumbItems(page, routeModules);
5759
});
5860
5961
// Generate breadcrumb items from the current route
@@ -156,23 +158,19 @@
156158
/**
157159
* Converts route segments to human-readable text
158160
*/
159-
function formatBreadcrumbText(text: string): string {
161+
/*function formatBreadcrumbText(text: string): string {
160162
// Handle special cases
161-
if (text === "ui") return "UI Components";
162-
if (text === "data-vis") return "Data Visualization";
163-
if (text === "content") return "Content Components";
164-
if (text === "layout") return "Layout Components";
165-
if (text === "user-guide") return "User Guide";
166-
if (text === "playground") return "Playground";
167-
if (text === "components") return "Components";
168-
if (text === "local-lib") return "Local Library";
163+
const urlLookupObject = {
164+
ui: "UI Components",
165+
"data-vis": "Data Visualization",
166+
};
169167
170168
// Default: capitalize and replace hyphens with spaces
171-
return text
169+
return (text in urlLookupObject ? urlLookupObject[text] : text)
172170
.split("-")
173171
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
174172
.join(" ");
175-
}
173+
}*/
176174
</script>
177175

178176
<nav

src/wrappers/components/layout/BreadcrumbsWrapper.svelte

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,34 @@
184184
category: "Accessibility",
185185
value: "Breadcrumb",
186186
},
187+
{
188+
name: "breadcrumbTextObject",
189+
category: "customisations",
190+
value: {
191+
ui: "UI Components",
192+
"data-vis": "Data Visualization",
193+
},
194+
},
195+
196+
{
197+
name: "formatBreadcrumbText",
198+
category: "customisations",
199+
value: function (text) {
200+
// Handle special cases
201+
const urlLookupObject = {
202+
ui: "UI Components",
203+
"data-vis": "Data Visualization",
204+
};
205+
206+
console.log("function is running");
207+
208+
// Default: capitalize and replace hyphens with spaces
209+
return (text in urlLookupObject ? urlLookupObject[text] : text)
210+
.split("-")
211+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
212+
.join(" ");
213+
},
214+
},
187215
]),
188216
);
189217

0 commit comments

Comments
 (0)