Browse Source

Implement 410 Gone page and redirects

gpt-engineer-app[bot] 1 month ago
parent
commit
d3c06c9ed8
5 changed files with 121 additions and 9 deletions
  1. 6 0
      public/robots.txt
  2. 8 0
      src/App.tsx
  3. 38 0
      src/components/LegacyRedirect.tsx
  4. 52 0
      src/pages/Gone.tsx
  5. 17 9
      src/pages/NotFound.tsx

+ 6 - 0
public/robots.txt

@@ -1,8 +1,12 @@
 User-agent: Googlebot
 Allow: /
+Disallow: /flux/
+Disallow: /account/
 
 User-agent: Bingbot
 Allow: /
+Disallow: /flux/
+Disallow: /account/
 
 User-agent: Twitterbot
 Allow: /
@@ -12,5 +16,7 @@ Allow: /
 
 User-agent: *
 Allow: /
+Disallow: /flux/
+Disallow: /account/
 
 Sitemap: https://feeds.duhaz.fr/sitemap.xml

+ 8 - 0
src/App.tsx

@@ -9,6 +9,8 @@ import Pinned from "./pages/Pinned";
 import FeedDetail from "./pages/FeedDetail";
 import NotFound from "./pages/NotFound";
 import Auth from "./pages/Auth";
+import Gone from "./pages/Gone";
+import LegacyRedirect from "./components/LegacyRedirect";
 
 const queryClient = new QueryClient();
 
@@ -24,6 +26,12 @@ const App = () => (
           <Route path="/pinned" element={<Pinned />} />
           <Route path="/feed/:feedId" element={<FeedDetail />} />
           <Route path="/auth" element={<Auth />} />
+          <Route path="/gone" element={<Gone />} />
+          
+          {/* Legacy URL redirects */}
+          <Route path="/flux/*" element={<LegacyRedirect />} />
+          <Route path="/account/*" element={<LegacyRedirect />} />
+          
           {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
           <Route path="*" element={<NotFound />} />
         </Routes>

+ 38 - 0
src/components/LegacyRedirect.tsx

@@ -0,0 +1,38 @@
+import { useEffect } from "react";
+import { useLocation, useNavigate } from "react-router-dom";
+
+const LegacyRedirect = () => {
+  const location = useLocation();
+  const navigate = useNavigate();
+
+  useEffect(() => {
+    const path = location.pathname;
+
+    console.log("LegacyRedirect: Checking path:", path);
+
+    // Redirection pour /flux/youtube-* → /feeds
+    if (path.startsWith("/flux/youtube")) {
+      console.log("Redirecting /flux/youtube-* to /feeds");
+      navigate("/feeds", { replace: true });
+      return;
+    }
+
+    // Redirection pour /account/* → /auth
+    if (path.startsWith("/account")) {
+      console.log("Redirecting /account/* to /auth");
+      navigate("/auth", { replace: true });
+      return;
+    }
+
+    // Redirection pour /flux/* → page 410
+    if (path.startsWith("/flux")) {
+      console.log("Redirecting /flux/* to /gone (410)");
+      navigate("/gone", { replace: true });
+      return;
+    }
+  }, [location, navigate]);
+
+  return null;
+};
+
+export default LegacyRedirect;

+ 52 - 0
src/pages/Gone.tsx

@@ -0,0 +1,52 @@
+import { useLocation, Link } from "react-router-dom";
+import { useEffect } from "react";
+import { SEO } from "@/components/SEO";
+
+const Gone = () => {
+  const location = useLocation();
+
+  useEffect(() => {
+    console.warn(
+      "410 Gone: User attempted to access permanently removed content:",
+      location.pathname
+    );
+  }, [location.pathname]);
+
+  return (
+    <>
+      <SEO
+        title="Contenu supprimé - 410 Gone"
+        description="Cette page n'existe plus. Le contenu a été définitivement supprimé ou déplacé."
+        canonical={`https://feeds.duhaz.fr${location.pathname}`}
+      />
+      <div className="min-h-screen flex items-center justify-center bg-background">
+        <div className="text-center max-w-2xl px-4">
+          <h1 className="text-6xl font-bold mb-4 text-foreground">410</h1>
+          <h2 className="text-2xl font-semibold mb-4 text-foreground">
+            Contenu définitivement supprimé
+          </h2>
+          <p className="text-lg text-muted-foreground mb-6">
+            Cette page n'existe plus. Le contenu a été supprimé ou déplacé
+            suite à une refonte du site.
+          </p>
+          <div className="flex flex-col sm:flex-row gap-4 justify-center">
+            <Link
+              to="/"
+              className="px-6 py-3 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition"
+            >
+              Accueil
+            </Link>
+            <Link
+              to="/feeds"
+              className="px-6 py-3 bg-secondary text-secondary-foreground rounded-lg hover:bg-secondary/90 transition"
+            >
+              Gérer mes flux
+            </Link>
+          </div>
+        </div>
+      </div>
+    </>
+  );
+};
+
+export default Gone;

+ 17 - 9
src/pages/NotFound.tsx

@@ -1,5 +1,6 @@
-import { useLocation } from "react-router-dom";
+import { useLocation, Link } from "react-router-dom";
 import { useEffect } from "react";
+import { SEO } from "@/components/SEO";
 
 const NotFound = () => {
   const location = useLocation();
@@ -12,15 +13,22 @@ const NotFound = () => {
   }, [location.pathname]);
 
   return (
-    <div className="min-h-screen flex items-center justify-center bg-gray-100">
-      <div className="text-center">
-        <h1 className="text-4xl font-bold mb-4">404</h1>
-        <p className="text-xl text-gray-600 mb-4">Oops! Page not found</p>
-        <a href="/" className="text-blue-500 hover:text-blue-700 underline">
-          Return to Home
-        </a>
+    <>
+      <SEO
+        title="Page non trouvée - 404"
+        description="La page que vous recherchez n'existe pas."
+        canonical={`https://feeds.duhaz.fr${location.pathname}`}
+      />
+      <div className="min-h-screen flex items-center justify-center bg-background">
+        <div className="text-center">
+          <h1 className="text-4xl font-bold mb-4 text-foreground">404</h1>
+          <p className="text-xl text-muted-foreground mb-4">Page non trouvée</p>
+          <Link to="/" className="text-primary hover:text-primary/90 underline">
+            Retour à l'accueil
+          </Link>
+        </div>
       </div>
-    </div>
+    </>
   );
 };