Files
erika/app/page.tsx
T

111 lines
4.6 KiB
TypeScript

import { config } from "@/lib/config";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader } from "@/components/ui/card";
import Image from "next/image";
import Link from "next/link";
import ShaderBackground from "@/components/ShaderBackground";
import { getFollowerCounts, getCountForLink, formatCount } from "@/lib/followers";
export default async function Home() {
const counts = await getFollowerCounts();
const jsonLd = {
"@context": "https://schema.org",
"@type": "ProfilePage",
name: config.profile.name,
description: config.profile.desc,
url: "https://erika.sudloh.com",
mainEntity: {
"@type": "Person",
name: config.profile.name,
image: "https://erika.sudloh.com/avatar.webp",
sameAs: config.links.map((l) => l.link),
},
};
return (
<main className="flex min-h-screen flex-col items-center justify-center p-4">
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
<video className="fixed top-0 left-0 w-full h-full -z-10 object-cover hidden md:block" autoPlay muted loop playsInline>
<source src="https://cdn.gunshiz.top/erika.mp4"></source>
</video>
<video className="fixed top-0 left-0 w-full h-full -z-10 object-cover md:hidden" autoPlay muted loop playsInline>
<source src="https://cdn.gunshiz.top/erika-mb.mp4"></source>
</video>
<Card className="w-full max-w-sm overflow-hidden relative bg-transparent border-0 backdrop-blur-md md:backdrop-blur-none md:bg-card md:border 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={config.profile.avatar}
alt={`${config.profile.name} avatar`}
fill
priority
className="object-cover"
/>
</div>
<div>
<h1 className="text-2xl font-bold bg-linear-to-r from-pink-500 to-yellow-200 bg-clip-text text-transparent">
{config.profile.name}
</h1>
<p className="text-sm text-zinc-400 mt-1">
{config.profile.desc}
</p>
</div>
</CardHeader>
<CardContent>
<nav aria-label="ลิ้งค์โซเชียลมีเดีย" className="flex flex-col gap-3">
{config.links.map((item, index) => {
const isStringIcon = typeof item.icon === "string";
const IconComponent = !isStringIcon ? item.icon : null;
const count = getCountForLink(item.name, counts);
return (
<Button
key={index}
variant="outline"
className="w-full h-auto p-4 group md:bg-muted bg-black/40 "
asChild
>
<Link href={item.link} target="_blank" rel="noopener noreferrer" className="w-full">
<div className="flex items-center justify-between w-full">
<div className="flex items-center gap-4">
<div className="shrink-0 w-8 h-8 flex items-center justify-center">
{isStringIcon ? (
<Image
src={item.icon as string}
alt={`${item.name} icon`}
width={24}
height={24}
className="object-contain"
/>
) : (
IconComponent && <IconComponent className="w-6 h-6 text-zinc-300" />
)}
</div>
<div className="flex flex-col items-start text-left">
<span className="font-semibold text-zinc-100">{item.name}</span>
{item.desc && <span className="text-xs text-zinc-400">{item.desc}</span>}
</div>
</div>
{count !== null && (
<span className="text-xs font-medium shrink-0">
{formatCount(count.count)}
<span className="text-zinc-400"> {count.label}</span>
</span>
)}
</div>
</Link>
</Button>
);
})}
</nav>
</CardContent>
</Card>
</main>
);
}