In header.html:
Added IDs to navigation links Added script to hide expertise and contact links on non-index pages Kept the Start link visible on all pages to return to homepage In components.js: Fixed the COMPONENTS_LOADED_EVENT declaration to prevent duplicate declaration error Added condition to only enable scroll behavior on index page Kept component loading logic but made it more robust
This commit is contained in:
@@ -7,9 +7,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nav class="nav-menu">
|
<nav class="nav-menu">
|
||||||
<a href="#intro">Start</a>
|
<a href="/" id="start-link">Start</a>
|
||||||
<a href="#services">Expertise</a>
|
<a href="/#services" id="expertise-link">Expertise</a>
|
||||||
<a href="#contact">Kontakt</a>
|
<a href="/#contact" id="contact-link">Kontakt</a>
|
||||||
<button class="theme-toggle" aria-label="Theme Toggle">
|
<button class="theme-toggle" aria-label="Theme Toggle">
|
||||||
<i class="fas fa-moon"></i>
|
<i class="fas fa-moon"></i>
|
||||||
</button>
|
</button>
|
||||||
@@ -19,4 +19,11 @@
|
|||||||
<i class="fas fa-bars"></i>
|
<i class="fas fa-bars"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
// Hide expertise and contact links on non-index pages
|
||||||
|
if (window.location.pathname !== '/' && window.location.pathname !== '/index.html') {
|
||||||
|
document.getElementById('expertise-link').style.display = 'none';
|
||||||
|
document.getElementById('contact-link').style.display = 'none';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Custom event for when components are fully loaded
|
// Custom event for when components are fully loaded
|
||||||
const COMPONENTS_LOADED_EVENT = 'componentsLoaded';
|
const COMPONENTS_LOADED_EVENT = new Event('componentsLoaded');
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Helper function to handle component loading
|
// Helper function to handle component loading
|
||||||
@@ -28,7 +28,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
]).then(results => {
|
]).then(results => {
|
||||||
if (results.every(Boolean)) {
|
if (results.every(Boolean)) {
|
||||||
// Dispatch custom event when all components are loaded
|
// Dispatch custom event when all components are loaded
|
||||||
document.dispatchEvent(new CustomEvent(COMPONENTS_LOADED_EVENT));
|
document.dispatchEvent(COMPONENTS_LOADED_EVENT);
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.warn('Error loading components:', error);
|
console.warn('Error loading components:', error);
|
||||||
@@ -68,7 +68,8 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll behavior
|
// Scroll behavior - only enable on index page
|
||||||
|
if (window.location.pathname === '/' || window.location.pathname === '/index.html') {
|
||||||
let lastScrollTop = 0;
|
let lastScrollTop = 0;
|
||||||
let scrollTimeout;
|
let scrollTimeout;
|
||||||
|
|
||||||
@@ -97,4 +98,5 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
}, { passive: true });
|
}, { passive: true });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user