's'
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useParams } from "next/navigation";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import Header from "../../components/Header";
|
||||
@@ -9,9 +10,20 @@ import { HOSTS } from "@/config/home.config";
|
||||
|
||||
export default function HostDetailPage() {
|
||||
const params = useParams();
|
||||
const router = useRouter();
|
||||
const id = typeof params.id === "string" ? params.id : "";
|
||||
const host = HOSTS.find((h) => h.id === id);
|
||||
|
||||
useEffect(() => {
|
||||
if (host && "link" in host && host.link) {
|
||||
if (host.link.startsWith("http")) {
|
||||
window.location.href = host.link;
|
||||
} else {
|
||||
router.replace(host.link);
|
||||
}
|
||||
}
|
||||
}, [host, router]);
|
||||
|
||||
if (!host) {
|
||||
return (
|
||||
<div className="min-h-screen bg-[#faf8f5] dark:bg-stone-950 flex items-center justify-center">
|
||||
@@ -25,6 +37,14 @@ export default function HostDetailPage() {
|
||||
);
|
||||
}
|
||||
|
||||
if ("link" in host && host.link) {
|
||||
return (
|
||||
<div className="min-h-screen bg-[#faf8f5] dark:bg-stone-950 flex items-center justify-center">
|
||||
<p className="text-stone-500 dark:text-stone-400">跳转中…</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[#faf8f5] dark:bg-stone-950">
|
||||
<Header />
|
||||
@@ -54,11 +74,13 @@ export default function HostDetailPage() {
|
||||
<p className="mt-2 text-sm text-amber-600 dark:text-amber-400">
|
||||
{host.bio}
|
||||
</p>
|
||||
<div className="mt-6 pt-6 border-t border-stone-100 dark:border-stone-700 text-left">
|
||||
<p className="text-sm text-stone-600 dark:text-stone-400 leading-relaxed">
|
||||
{host.intro}
|
||||
</p>
|
||||
</div>
|
||||
{"intro" in host && host.intro && (
|
||||
<div className="mt-6 pt-6 border-t border-stone-100 dark:border-stone-700 text-left">
|
||||
<p className="text-sm text-stone-600 dark:text-stone-400 leading-relaxed">
|
||||
{host.intro}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user