Skip to content

Commit 67c3026

Browse files
updated ui
1 parent d2ecb88 commit 67c3026

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

assets/js/generateBreadcrumb.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
function generateBreadCrumb() {
22
const breadCrumbContainer = document.getElementById("breadcrumb");
33

4+
// Get current path or use simulated path
5+
let currentPath = window.simulatedPath || window.location.pathname;
6+
47
// Split the pathname into parts
5-
let pathArray = window.location.pathname.split("/").filter((p) => p);
8+
let pathArray = currentPath
9+
.split("/")
10+
.filter((p) => p && p.toLowerCase() !== "index.html");
611

712
// Detect repo name (first segment)
813
const repoName = pathArray.length > 0 ? pathArray[0] : "";
9-
const basePath = `/${repoName}`;
14+
const basePath = repoName ? `/${repoName}` : "";
1015

1116
// Remove repo name from breadcrumb segments
1217
if (repoName) {
1318
pathArray.shift();
1419
}
1520

16-
// If last segment is index.html, drop it
17-
if (pathArray[pathArray.length - 1]?.toLowerCase() === "index.html") {
18-
pathArray.pop();
19-
}
20-
21-
// Start breadcrumb with monitor icon (always links to repo root index.html)
21+
// Start breadcrumb with home icon (always links to repo root index.html)
2222
let breadcrumbHTML = `
23-
<a href="${basePath}/index.html">
24-
<img src="${basePath}/assets/Icons/monitor.png" style="width: 30px;"/>
25-
</a>
26-
`;
23+
<a href="${basePath}/index.html" title="Home">
24+
<img src="${basePath}/assets/Icons/monitor.png" alt="Home" style="width: 24px; height: 24px;"/>
25+
</a>
26+
`;
2727

28-
let fullPath = "";
28+
let accumulatedPath = basePath;
29+
30+
// Generate breadcrumb segments
2931
pathArray.forEach((segment, index) => {
30-
fullPath += `/${segment}`;
31-
const isLast = index === pathArray.length - 1;
32+
// Add arrow before each segment (except first one which is handled by home icon)
33+
breadcrumbHTML += `<img src="${basePath}/assets/Icons/arrow_right.png" alt="→" style="width: 16px; height: 16px; margin: 0 10px;" />`;
3234

33-
// Add arrow only if it's not the last segment
34-
breadcrumbHTML += isLast
35-
? " "
36-
: `<img src="${basePath}/assets/Icons/arrow_right.png" style="width: 20px; height: 20px;"/>`;
35+
accumulatedPath += `/${segment}`;
36+
const isLast = index === pathArray.length - 1;
3737

3838
if (!isLast) {
39-
breadcrumbHTML += `<a href="${basePath}${fullPath}">${decodeURIComponent(
39+
breadcrumbHTML += `<a href="${accumulatedPath}">${decodeURIComponent(
4040
segment
4141
)}</a>`;
4242
} else {
43-
breadcrumbHTML += `<span>${decodeURIComponent(segment)}</span>`;
43+
// For the last segment, remove .html if present
44+
const displayName = segment.replace(/\.(html|php|aspx)$/i, "");
45+
breadcrumbHTML += `<span>${decodeURIComponent(displayName)}</span>`;
4446
}
4547
});
4648

0 commit comments

Comments
 (0)