Fix: detection navigation SPA pour page team

This commit is contained in:
syoul
2025-12-09 19:26:54 +01:00
parent 89c24b9cd8
commit cdd6e1c573

View File

@@ -2,14 +2,27 @@
(function() {
'use strict';
var path = window.location.pathname;
var isTeamRoute = path === '/team' || path === '/team/' || path.startsWith('/team/');
if (!isTeamRoute) {
return;
// Fonction pour verifier si on est sur la route team
function isTeamRoute() {
var path = window.location.pathname;
return path === '/team' || path === '/team/' || path.startsWith('/team/');
}
console.log('EQUIPE: Page team detectee, preparation du remplacement DOM');
// Fonction pour verifier et initialiser la page team
function checkAndInitTeamPage() {
if (!isTeamRoute()) {
return;
}
// Eviter double initialisation
if (window.__teamPageInitialized) {
return;
}
window.__teamPageInitialized = true;
console.log('EQUIPE: Page team detectee, preparation du remplacement DOM');
initTeamPage();
}
// Fonction pour charger un script externe
function loadScript(src) {
@@ -321,8 +334,18 @@
// Demarrer quand le DOM est pret
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initTeamPage);
document.addEventListener('DOMContentLoaded', checkAndInitTeamPage);
} else {
initTeamPage();
checkAndInitTeamPage();
}
// Detecter les navigations Next.js (SPA)
var lastUrl = location.href;
new MutationObserver(function() {
if (location.href !== lastUrl) {
lastUrl = location.href;
window.__teamPageInitialized = false;
checkAndInitTeamPage();
}
}).observe(document, { subtree: true, childList: true });
})();