-
-
Save rakib86/c944a860673b7617aa4b609d1bb96388 to your computer and use it in GitHub Desktop.
demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Link from 'next/link'; | |
import type { Metadata } from 'next'; | |
import { notFound } from 'next/navigation'; | |
import { getSubdomainData } from '@/lib/subdomains'; | |
import { protocol, rootDomain } from '@/lib/utils'; | |
export async function generateMetadata({ | |
params | |
}: { | |
params: Promise<{ subdomain: string }>; | |
}): Promise<Metadata> { | |
const { subdomain } = await params; | |
const subdomainData = await getSubdomainData(subdomain); | |
if (!subdomainData) { | |
return { | |
title: rootDomain | |
}; | |
} | |
return { | |
title: `${subdomain}.${rootDomain}`, | |
description: `Subdomain page for ${subdomain}.${rootDomain}` | |
}; | |
} | |
export default async function SubdomainPage({ | |
params | |
}: { | |
params: Promise<{ subdomain: string }>; | |
}) { | |
const { subdomain } = await params; | |
const subdomainData = await getSubdomainData(subdomain); | |
if (!subdomainData) { | |
notFound(); | |
} | |
return ( | |
<div className="flex min-h-screen flex-col bg-gradient-to-b from-blue-50 to-white p-4"> | |
<div className="absolute top-4 right-4"> | |
<Link | |
href={`${protocol}://${rootDomain}`} | |
className="text-sm text-gray-500 hover:text-gray-700 transition-colors" | |
> | |
{rootDomain} | |
</Link> | |
</div> | |
<div className="flex-1 flex items-center justify-center"> | |
<div className="text-center"> | |
<div className="text-9xl mb-6">{subdomainData.emoji}</div> | |
<h1 className="text-4xl font-bold tracking-tight text-gray-900"> | |
Welcome to {subdomain}.{rootDomain} | |
</h1> | |
<p className="mt-3 text-lg text-gray-600"> | |
This is your custom subdomain page | |
</p> | |
</div> | |
</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment