-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
33 lines (29 loc) · 863 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
document.addEventListener("DOMContentLoaded", () => {
const links = document.querySelectorAll("a[data-link]");
links.forEach((link) => {
link.addEventListener("click", (event) => {
event.preventDefault();
const url = link.getAttribute("href");
history.pushState(null, null, url);
handleNavigation();
});
});
window.addEventListener("popstate", handleNavigation);
function handleNavigation() {
const path = window.location.pathname;
let page = "index";
if (path === "/eresume") {
page = "eresume";
}
fetch(`${page}.html`)
.then((response) => response.text())
.then((html) => {
document.getElementById("content").innerHTML = html;
});
}
window.navigateTo = (url) => {
history.pushState(null, null, url);
handleNavigation();
};
handleNavigation();
});