import Link from 'next/link'; import type { Post } from 'contentlayer/generated'; interface Props { current: Post; newer?: Post; older?: Post; } interface StationConfig { key: 'older' | 'newer'; label: string; post?: Post; rel?: 'prev' | 'next'; subtitle: string; align: 'start' | 'end'; } export function PostStorylineNav({ current, newer, older }: Props) { const stations: StationConfig[] = [ { key: 'older', label: '上一站', post: older, subtitle: older ? '回顧這篇' : '到達起點', rel: 'prev', align: 'end' }, { key: 'newer', label: '下一站', post: newer, subtitle: newer ? '繼續前往' : '尚無新章', rel: 'next', align: 'start' } ]; return ( ); } function Station({ station }: { station: StationConfig }) { const { post, label, subtitle, rel, align } = station; const alignClass = align === 'end' ? 'items-end text-right' : 'items-start text-left'; if (!post) { return (
{label}
{subtitle}
{label}
{post.title}
{subtitle} ); }