import { Alert, AlertDescription, AlertTitle, } from "@/components/ui/alert"; import { AlertCircle } from "lucide-react"; import { base62 } from "@/lib/utils"; import { BlogAPI } from "@/lib/api/server"; import { handleAPIError } from "@/lib/api/common"; const formatNumber = (num: number): string => { if (num >= 1_000_000) { return (num / 1_000_000).toFixed(1) + 'M'; } if (num >= 1_000) { return (num / 1_000).toFixed(1) + 'K'; } return num.toString(); }; const getBlogDetailUrl = (id: string): string => { const cleanId = id.replace(/-/g, ''); const encoded = base62.encode(Buffer.from(cleanId, 'hex')); return `/blog/${encoded}`; }; export const metadata = { title: '日志 - 特恩的日志', description: '我随便发点,你也随便看看~', }; export default async function Blog() { let errorMsg = ''; const blogs = await BlogAPI.list().catch(e => { handleAPIError(e, ({ message }) => { errorMsg = message }); return null; }); return (
{ errorMsg && ( 出错啦 {errorMsg} ) } { blogs && blogs.map((blog) => (

{blog.title}

{blog.description}

)) }
) }