nomadro/app/community/destinations/[slug]/page.tsx
eric 9928c5185b Mount nav/book/community as native App Router routes in one Next process.
Replace reverse-proxy/iframe approach with @ebook/@community/@navmini imports under /nav /book /community so localhost:3000 serves all three products directly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 03:49:16 -05:00

77 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Link from "next/link";
import type { Metadata } from "next";
import { api } from "@community/lib/api";
import { notFound } from "next/navigation";
import FavoriteButton from "@community/components/FavoriteButton";
import DestinationDetailClient from "@community/components/DestinationDetailClient";
import SiteShell from "@community/components/SiteShell";
export async function generateMetadata(
{ params }: { params: Promise<{ slug: string }> }
): Promise<Metadata> {
const { slug } = await params;
try {
const dest = await api.getDestination(slug);
const title = `${dest.emoji} ${dest.name}, ${dest.country} · nomadro`;
const description = `${dest.description.slice(0, 120)}… 月费约 ¥${dest.cost.toLocaleString()} · 网速 ${dest.speed}Mbps`;
return {
title,
description,
openGraph: { title, description, url: `/destinations/${slug}` },
twitter: { card: "summary_large_image", title, description },
};
} catch {
return { title: "目的地 · nomadro" };
}
}
export default async function DestinationPage({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params;
let dest;
let allDestinations;
try {
[dest, allDestinations] = await Promise.all([
api.getDestination(slug),
api.getDestinations(),
]);
} catch {
notFound();
}
return (
<SiteShell>
<div className="detail-page">
<nav className="detail-nav">
<Link href="/community/#destinations">← 返回目的地</Link>
</nav>
<div className="dest-detail">
<div className="dest-detail-hero" style={{ background: `linear-gradient(135deg,hsl(${dest.hue},60%,20%),hsl(${dest.hue + 40},50%,30%))` }}>
<span className="dest-detail-emoji">{dest.emoji}</span>
</div>
<div className="dest-detail-body">
<div className="dest-detail-top">
<div>
<span className="modal-tag">{dest.tag}</span>
<h1>{dest.name}, {dest.country}</h1>
</div>
<FavoriteButton slug={dest.slug} />
</div>
<p className="dest-detail-desc">{dest.description}</p>
<div className="modal-stats">
<div className="modal-stat"><span className="stat-emoji">💰</span><strong>¥{dest.cost.toLocaleString()}</strong><span>月生活费</span></div>
<div className="modal-stat"><span className="stat-emoji">📶</span><strong>{dest.speed}Mbps</strong><span>网速</span></div>
<div className="modal-stat"><span className="stat-emoji">🌡️</span><strong>{dest.temperature}°C</strong><span>均温</span></div>
<div className="modal-stat"><span className="stat-emoji">⭐</span><strong>{dest.rating}</strong><span>评分</span></div>
</div>
<div className="modal-highlights">
<h4>✨ 亮点特色</h4>
<ul>{dest.highlights.map((h) => <li key={h}>{h}</li>)}</ul>
</div>
<DestinationDetailClient dest={dest} allDestinations={allDestinations} />
</div>
</div>
</div>
</SiteShell>
);
}