Fix: detection navigation SPA pour page team
This commit is contained in:
@@ -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 });
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user