-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
KHOUBZA Younes
committed
May 29, 2022
1 parent
8ec5f80
commit 8185668
Showing
9 changed files
with
67 additions
and
16 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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
createAnchorNavigation(); | ||
highlightCurrentAnchor(); | ||
|
||
const links = document.querySelectorAll('a.anchor, #anchor-navigation ul li a'); | ||
links.forEach((anchor) => { | ||
anchor.addEventListener('click', (event) => { | ||
event.preventDefault(); | ||
|
||
window.location.hash = anchor.hash; | ||
highlightCurrentAnchor(anchor.hash); | ||
}); | ||
}); | ||
|
||
function createAnchorNavigation() { | ||
const container = document.querySelector('#anchor-navigation ul'); | ||
const anchors = document.querySelectorAll('a.anchor'); | ||
|
||
anchors.forEach((anchor) => { | ||
const link = document.createElement('a'); | ||
link.href = anchor.hash; | ||
link.innerText = anchor.innerText; | ||
link.classList.add('leading-loose', 'text-md', 'w-full', 'text-indigo-500'); | ||
|
||
const li = document.createElement('li'); | ||
li.classList.add('px-6', 'rounded', 'w-36'); | ||
li.appendChild(link); | ||
|
||
container.appendChild(li); | ||
}); | ||
} | ||
|
||
function highlightCurrentAnchor(hash) { | ||
if (typeof hash === 'undefined') { | ||
hash = window.location.hash; | ||
} | ||
|
||
const links = document.querySelectorAll('a.anchor, #anchor-navigation ul li a'); | ||
links.forEach((link) => { | ||
const parent = link.parentElement; | ||
link.classList.remove('text-gray-900'); | ||
link.classList.add('text-indigo-500'); | ||
parent.classList.remove('bg-indigo-500'); | ||
|
||
if (hash === link.hash) { | ||
link.classList.remove('text-indigo-500'); | ||
link.classList.add('text-white'); | ||
|
||
parent.classList.add('bg-indigo-500'); | ||
} | ||
}); | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 +1,6 @@ | ||
module.exports = { | ||
content: [ | ||
"./_site/**/*.html", | ||
"./_site/**/*.js", | ||
], | ||
} |