fix: liens du menu pointant vers la page d'accueil

This commit is contained in:
2026-07-06 09:47:19 +04:00
parent a1e39b88bf
commit 711244235f
3 changed files with 24 additions and 22 deletions
+6 -4
View File
@@ -69,12 +69,14 @@
themeToggle?.addEventListener('click', toggleTheme);
})();
// Smooth scrolling
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
// Smooth scrolling (uniquement pour les ancres de la page courante)
document.querySelectorAll('a[href*="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
const url = new URL(this.href, window.location.href);
if (url.pathname !== window.location.pathname || !url.hash) return;
const target = document.querySelector(url.hash);
if (target) {
e.preventDefault();
target.scrollIntoView({
behavior: 'smooth',
block: 'start'