fix: amélioration script create-team-page avec iframe et awk

- Page Next.js utilise iframe pour charger team.html (plus simple)
- Utilisation d'awk pour modification Navigation.tsx (plus robuste)
- Meilleure gestion des erreurs
This commit is contained in:
syoul
2025-12-06 22:15:05 +01:00
parent 7bc6c695b8
commit df4948c19a

View File

@@ -6,56 +6,31 @@ TECHRADAR_DIR=".techradar"
TEAM_PAGE="$TECHRADAR_DIR/src/pages/team.tsx" TEAM_PAGE="$TECHRADAR_DIR/src/pages/team.tsx"
NAV_FILE="$TECHRADAR_DIR/src/components/Navigation/Navigation.tsx" NAV_FILE="$TECHRADAR_DIR/src/components/Navigation/Navigation.tsx"
# Créer la page team.tsx # Créer la page team.tsx qui charge team.html via iframe (plus simple et fiable)
if [ ! -f "$TEAM_PAGE" ]; then if [ ! -f "$TEAM_PAGE" ]; then
mkdir -p "$(dirname "$TEAM_PAGE")" mkdir -p "$(dirname "$TEAM_PAGE")"
cat > "$TEAM_PAGE" << 'EOF' cat > "$TEAM_PAGE" << 'EOF'
import Head from "next/head"; import Head from "next/head";
import { useEffect } from "react";
import { CustomPage } from "@/pages/_app"; import { CustomPage } from "@/pages/_app";
const TeamPage: CustomPage = () => { const TeamPage: CustomPage = () => {
useEffect(() => {
// Charger le contenu de team.html dans cette page
const loadTeamPage = async () => {
try {
const response = await fetch('/team.html');
if (response.ok) {
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const content = doc.body.innerHTML;
const container = document.getElementById('team-container');
if (container) {
container.innerHTML = content;
// Réexécuter les scripts
const scripts = container.querySelectorAll('script');
scripts.forEach(oldScript => {
const newScript = document.createElement('script');
Array.from(oldScript.attributes).forEach(attr => {
newScript.setAttribute(attr.name, attr.value);
});
newScript.textContent = oldScript.textContent;
oldScript.parentNode?.replaceChild(newScript, oldScript);
});
}
}
} catch (error) {
console.error('Erreur lors du chargement de team.html:', error);
}
};
loadTeamPage();
}, []);
return ( return (
<> <>
<Head> <Head>
<title>Équipe & Technologies - Laplank</title> <title>Équipe & Technologies - Laplank</title>
</Head> </Head>
<div id="team-container" style={{ minHeight: '100vh' }}> <div style={{ width: '100%', height: '100vh', border: 'none', margin: 0, padding: 0 }}>
<div style={{ textAlign: 'center', padding: '40px' }}> <iframe
<p>Chargement de la page Équipe...</p> src="/team.html"
</div> style={{
width: '100%',
height: '100%',
border: 'none',
margin: 0,
padding: 0
}}
title="Équipe & Technologies"
/>
</div> </div>
</> </>
); );
@@ -63,7 +38,7 @@ const TeamPage: CustomPage = () => {
export default TeamPage; export default TeamPage;
EOF EOF
echo "✅ Page team.tsx créée" echo "✅ Page team.tsx créée (iframe)"
else else
echo " Page team.tsx existe déjà" echo " Page team.tsx existe déjà"
fi fi
@@ -71,18 +46,28 @@ fi
# Modifier Navigation.tsx pour ajouter le lien # Modifier Navigation.tsx pour ajouter le lien
if [ -f "$NAV_FILE" ]; then if [ -f "$NAV_FILE" ]; then
if ! grep -q 'href="/team"' "$NAV_FILE"; then if ! grep -q 'href="/team"' "$NAV_FILE"; then
# Ajouter le lien après Overview # Ajouter le lien après Overview, avant le commentaire
sed -i '/href="\/overview"/a\ # Utiliser une approche plus robuste avec awk ou perl
<li className={styles.item}>\ awk '
<Link href="/team">\ /href="\/overview"/ {
<span className={styles.label}>👥 Équipe</span>\ print
</Link>\ getline
</li>' "$NAV_FILE" print
print " <li className={styles.item}>"
print " <Link href=\"/team\">"
print " <span className={styles.label}>👥 Équipe</span>"
print " </Link>"
print " </li>"
next
}
{ print }
' "$NAV_FILE" > "$NAV_FILE.tmp" && mv "$NAV_FILE.tmp" "$NAV_FILE"
echo "✅ Lien Équipe ajouté au composant Navigation" echo "✅ Lien Équipe ajouté au composant Navigation"
else else
echo " Lien Équipe déjà présent dans Navigation" echo " Lien Équipe déjà présent dans Navigation"
fi fi
else else
echo "⚠️ Navigation.tsx non trouvé" echo "⚠️ Navigation.tsx non trouvé: $NAV_FILE"
ls -la "$(dirname "$NAV_FILE")" || echo "Dossier non trouvé"
fi fi