Skip to content

Commit

Permalink
Add custom 404 pages 🙈
Browse files Browse the repository at this point in the history
  • Loading branch information
wotschofsky committed Dec 20, 2023
1 parent 5723f8b commit c87202a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/lookup/[domain]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExternalLinkIcon } from 'lucide-react';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { type FC, type ReactNode, Suspense } from 'react';

import RelatedDomains from '@/components/RelatedDomains';
Expand All @@ -8,6 +9,7 @@ import SearchForm from '@/components/SearchForm';
import WhoisQuickInfo, {
WhoisQuickInfoPlaceholder,
} from '@/components/WhoisQuickInfo';
import isValidDomain from '@/utils/isValidDomain';

type LookupLayoutProps = {
children: ReactNode;
Expand Down Expand Up @@ -37,6 +39,10 @@ const LookupLayout: FC<LookupLayoutProps> = ({
children,
params: { domain },
}) => {
if (!isValidDomain(domain)) {
return notFound();
}

return (
<>
<div className="container mb-8 max-w-xl">
Expand Down
12 changes: 12 additions & 0 deletions app/lookup/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { type FC } from 'react';

const LookupNotFound: FC = () => (
<div className="mt-12 flex flex-col items-center gap-2">
<h2>404 - Not Found</h2>
<p className="mt-2 text-center text-sm text-muted-foreground">
Not a valid domain
</p>
</div>
);

export default LookupNotFound;
12 changes: 12 additions & 0 deletions app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { type FC } from 'react';

const GlobalNotFound: FC = () => (
<div className="mt-12 flex flex-col items-center gap-2">
<h2>404 - Not Found</h2>
<p className="mt-2 text-center text-sm text-muted-foreground">
This page doesn&apos;t exist
</p>
</div>
);

export default GlobalNotFound;

1 comment on commit c87202a

@vercel
Copy link

@vercel vercel bot commented on c87202a Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.