From 03d1d84c6f8f781711260aad0023ab1ff5f5a7b3 Mon Sep 17 00:00:00 2001 From: Vladislav Sokov Date: Tue, 21 May 2024 13:51:39 +0300 Subject: [PATCH] fix redirect from the old showcases URLs --- public/_redirects | 2 -- src/app/not-found.tsx | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) delete mode 100644 public/_redirects diff --git a/public/_redirects b/public/_redirects deleted file mode 100644 index 7fa66c9..0000000 --- a/public/_redirects +++ /dev/null @@ -1,2 +0,0 @@ -/showcase-1-stripe-integration /showcases/stripe-integration 304 -/showcase-2-prevent-account-sharing /showcases/prevent-account-sharing 304 \ No newline at end of file diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 867384c..c8651ca 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,6 +1,24 @@ -import Link from 'next/link' +'use client' + +import { useEffect } from 'react'; +import { useRouter } from 'next/navigation'; +import Link from 'next/link'; export default function NotFoundPage() { + const router = useRouter(); + + useEffect(() => { + const redirects: { [key: string]: string } = { + '/showcase-1-stripe-integration': '/showcases/stripe-integration', + '/showcase-2-prevent-account-sharing': '/showcases/prevent-account-sharing' + }; + + const path = window.location.pathname; + if (redirects[path]) { + router.replace(redirects[path]); + } + }, [router]); + return (