generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
424f726
commit d2601e1
Showing
9 changed files
with
28,580 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
const getPath = () => { | ||
const path = window.location.pathname | ||
if (path === '/') { | ||
return ['Home', 'Services', 'Water', 'Water supply', 'Water pressure']; | ||
} | ||
return path.split('/').filter((item) => item !== ''); | ||
} | ||
|
||
export default function decorate(block) { | ||
const title = block.querySelector('p'); | ||
block.innerHTML = ` | ||
<div class="breadcrumb-content"> | ||
<h1>${title?.innerText}</h1> | ||
</div>`; | ||
const breadcrumb = document.createElement('div'); | ||
const path = getPath(); | ||
const list = document.createElement('ul'); | ||
|
||
path.forEach((item, index) => { | ||
const li = document.createElement('li'); | ||
const a = document.createElement('a'); | ||
if (index < path.length - 1) { | ||
a.href = '#'; | ||
a.innerText = item; | ||
li.append(a) | ||
} else { | ||
li.innerText = item; | ||
} | ||
|
||
|
||
list.append(li); | ||
}); | ||
|
||
breadcrumb.className = 'breadcrumb-content' | ||
breadcrumb.innerHTML = `<h1>${title?.innerText}</h1>`; | ||
|
||
block.innerHTML = ''; | ||
breadcrumb.prepend(list); | ||
block.append(breadcrumb); | ||
} |
Oops, something went wrong.