89 lines
2.8 KiB
TypeScript
89 lines
2.8 KiB
TypeScript
import { config } from "@/lib/config";
|
|
import { Card, CardHeader } from "@/components/ui/card";
|
|
import Image from "next/image";
|
|
import { getFollowerCounts } from "@/lib/followers";
|
|
import { LinkCard } from "@/components/LinkCard";
|
|
import { headers } from "next/headers";
|
|
import { Users } from "lucide-react";
|
|
import { Kbd } from "@/components/ui/kbd";
|
|
import Background from "@/public/background/space.webp";
|
|
import { trackUniqueVisitor } from "@/lib/visitor/unique-visitors";
|
|
|
|
export default async function Home() {
|
|
const visitorCountPromise = headers()
|
|
.then(trackUniqueVisitor)
|
|
.catch((error) => {
|
|
console.error("Failed to track visitor:", error);
|
|
return 0;
|
|
});
|
|
const [{ counts }, visitorCount] = await Promise.all([
|
|
getFollowerCounts(),
|
|
visitorCountPromise,
|
|
]);
|
|
|
|
// Use configured profile data.
|
|
const profileName = config.profile.name;
|
|
const profileAvatar = config.profile.avatar;
|
|
const links1 = config.links;
|
|
|
|
const jsonLd = {
|
|
"@context": "https://schema.org",
|
|
"@type": "ProfilePage",
|
|
name: profileName,
|
|
description: config.profile.desc,
|
|
url: config.site.url,
|
|
mainEntity: {
|
|
"@type": "Person",
|
|
name: profileName,
|
|
image: profileAvatar.startsWith("/") ? `${config.site.url}${profileAvatar}` : profileAvatar,
|
|
sameAs: links1.map((l) => l.link),
|
|
},
|
|
};
|
|
|
|
|
|
return (
|
|
<main className="relative flex min-h-screen flex-col items-center justify-center bg-background p-4 text-foreground">
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
|
/>
|
|
<Image
|
|
src={Background}
|
|
alt="Background"
|
|
fill
|
|
priority
|
|
className="fixed top-0 left-0 z-0 h-full w-full object-cover opacity-60"
|
|
/>
|
|
<Card className="relative z-10 w-full max-w-sm bg-card/90 backdrop-blur md:max-w-lg" role="article">
|
|
<CardHeader className="flex flex-col items-center gap-4 text-center">
|
|
<div className="relative w-24 h-24 overflow-hidden rounded-full">
|
|
<Image
|
|
src={profileAvatar}
|
|
alt={`${profileName} avatar`}
|
|
fill
|
|
sizes="96px"
|
|
priority
|
|
className="object-cover"
|
|
/>
|
|
</div>
|
|
<div>
|
|
<h1 className="text-2xl font-bold text-primary">
|
|
{profileName}
|
|
</h1>
|
|
{visitorCount > 0 && (
|
|
<div className="mt-3 flex justify-center">
|
|
<Kbd>
|
|
<Users className="size-3.5" />
|
|
<span>{visitorCount} Unique Visitors</span>
|
|
</Kbd>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</CardHeader>
|
|
|
|
<LinkCard counts={counts} links1={links1} links2={config.secondaryLinks} />
|
|
</Card>
|
|
</main>
|
|
);
|
|
}
|