@@ -2,35 +2,33 @@ function generateBreadCrumb() {
22 const breadCrumbContainer = document . getElementById ( "breadcrumb" ) ;
33 let pathArray = window . location . pathname . split ( "/" ) . filter ( ( p ) => p ) ;
44
5+ const repoName = "javascript-course-notes" ;
6+ const basePath = `/${ repoName } ` ;
7+
58 // If last segment is index.html, drop it
69 if ( pathArray [ pathArray . length - 1 ] ?. toLowerCase ( ) === "index.html" ) {
710 pathArray . pop ( ) ;
811 }
912
1013 let breadcrumbHTML = `
11- <a href="/index.html">
12- <img src="../../.. /assets/Icons/monitor.png" style="width: 30px;"/>
14+ <a href="${ basePath } /index.html">
15+ <img src="${ basePath } /assets/Icons/monitor.png" style="width: 30px;"/>
1316 </a>
14- <img src="../../.. /assets/Icons/arrow_right.png" style="width: 20px; height: 20px;"/>
17+ <img src="${ basePath } /assets/Icons/arrow_right.png" style="width: 20px; height: 20px;"/>
1518 ` ;
1619
1720 let fullPath = "" ;
1821 pathArray . forEach ( ( segment , index ) => {
1922 fullPath += `/${ segment } ` ;
2023 const isLast = index === pathArray . length - 1 ;
2124
22- breadcrumbHTML += `
23-
24- ` ;
25-
2625 if ( ! isLast ) {
27- breadcrumbHTML += `<a href="${ fullPath } ">${ decodeURIComponent (
26+ breadcrumbHTML += `<a href="${ basePath } ${ fullPath } ">${ decodeURIComponent (
2827 segment
2928 ) } </a>
30- <img src="../../.. /assets/Icons/arrow_right.png" style="width: 20px; height: 20px;"/>` ;
29+ <img src="${ basePath } /assets/Icons/arrow_right.png" style="width: 20px; height: 20px;"/>` ;
3130 } else {
32- breadcrumbHTML += `<span>${ decodeURIComponent ( segment ) } </span>
33- <img src="../../../assets/Icons/arrow_right.png" style="width: 20px; height: 20px;"/>` ;
31+ breadcrumbHTML += `<span>${ decodeURIComponent ( segment ) } </span>` ;
3432 }
3533 } ) ;
3634
0 commit comments