leilukin-site/js/main-components.js

45 lines
1.7 KiB
JavaScript
Raw Normal View History

/* ------ MAIN HEADER COMPONENT ------ */
document.querySelector(".main-header").innerHTML = `
2023-06-27 14:57:47 +00:00
<img src="/assets/Leilukins-Hub-website-banner.png" alt="">
`;
2023-07-26 07:40:22 +00:00
/* ------ MAIN NAVIGATION BAR COMPONENT ------ */
document.querySelector(".navbar").innerHTML = `
2023-06-27 14:57:47 +00:00
<ul class="nav__menu">
2023-07-26 07:40:22 +00:00
<li><a href="/home.html">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/blog/">Blog</a></li>
<li><a href="/articles/">Articles</a></li>
<li><a href="/mycreations/">My Creations</a></li>
<li><a href="/mymods/">My Mods</a></li>
<li><a href="/playlists/">Playlists</a></li>
<li><a href="/featured/">Featured</a></li>
<li><a href="/resources/">Resources</a></li>
<li><a href="/shrines/">Shrines</a></li>
<li><a href="/links/">Links</a></li>
<li><a href="https://leilukin.123guestbook.com/">Guestbook</a></li>
2023-06-27 14:57:47 +00:00
</ul>
2023-07-26 07:40:22 +00:00
`;
// Make the navigation bar sticky
const header = document.querySelector(".main-header");
const navbar = document.querySelector(".navbar");
2023-07-26 07:40:22 +00:00
window.addEventListener("scroll", e => {
const scrollPos = window.scrollY || document.documentElement.scrollTop;
const stickyLine = header.scrollHeight - navbar.scrollHeight;
if (scrollPos > stickyLine) {
navbar.classList.add("sticky-nav");
} else {
navbar.classList.remove("sticky-nav");
}
});
/* ------ MAIN FOOTER COMPONENT ------ */
document.querySelector(".main-footer").innerHTML = `
<p>Made with by Leilukin | <a href="/sitemap.html">Site Map</a></p>
<p>Site Launched: September 11, 2022 | <a href="/changelog">Website Changelog</a></p>
<p><a href="#page-top"> Back to top </a></p>
`;