Skip to content

Commit

Permalink
fix redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavSokov committed May 22, 2024
1 parent 7161a54 commit 5080564
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 26 deletions.
18 changes: 0 additions & 18 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
'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 (
<main className="not-found">
<div className="container">
Expand Down
14 changes: 14 additions & 0 deletions src/app/showcase-1-stripe-integration/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default function StripeIntegrationLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<>
<head>
<meta httpEquiv="refresh" content="0; url=/showcases/stripe-integration" />
</head>
{children}
</>
);
}
7 changes: 7 additions & 0 deletions src/app/showcase-1-stripe-integration/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function StripeIntegration() {
return (
<main>
<p>Redirect</p>
</main>
);
};
14 changes: 14 additions & 0 deletions src/app/showcase-2-prevent-account-sharing/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default function PreventAccountSharingLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<>
<head>
<meta httpEquiv="refresh" content="0; url=/showcases/prevent-account-sharing" />
</head>
{children}
</>
);
}
7 changes: 7 additions & 0 deletions src/app/showcase-2-prevent-account-sharing/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function PreventAccountSharing() {
return (
<main>
<p>Redirect</p>
</main>
);
};
6 changes: 1 addition & 5 deletions src/app/showcases/[slug]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ export async function generateMetadata({ params } : Props): Promise<Metadata> {
}

export async function generateStaticParams() {
const slugs = showcases.map(showcase => (
{
slug: showcase.slug
})
);
const slugs = showcases.map(showcase => ({ slug: showcase.slug }));

return slugs;
}
Expand Down
3 changes: 0 additions & 3 deletions src/showcases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export interface ShowcaseBody {
}

export interface Showcase {
id: number;
category: CategoryName;
slug: string;
preview: ShowcasePreview;
Expand All @@ -75,7 +74,6 @@ export interface Showcase {

const showcases: Showcase[] = [
{
id: 1,
slug: "stripe-integration",
category: CategoryName.systemsIntegrations,
preview: {
Expand Down Expand Up @@ -174,7 +172,6 @@ const showcases: Showcase[] = [
}
},
{
id: 2,
slug: "prevent-account-sharing",
category: CategoryName.optimisations,
preview: {
Expand Down

0 comments on commit 5080564

Please sign in to comment.