'use client'; import { BlogApi } from "@/lib/api"; import { base62 } from "@/lib/utils"; import { useParams } from "next/navigation"; import useSWR from "swr"; import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import rehypeHighlight from 'rehype-highlight' import 'highlight.js/styles/github.css' export default function Blog() { const params = useParams(); const hex = Array.from(base62.decode(params.id as string)).map(b => b.toString(16).padStart(2, '0')).join(''); const id = [ hex.slice(0, 8), hex.slice(8, 12), hex.slice(12, 16), hex.slice(16, 20), hex.slice(20, 32) ].join('-'); const { data, error, isLoading } = useSWR( `/api/blog/${id}`, () => BlogApi.get(id), ) return (
{data && (

{data.title}

发布于:{new Date(data.createdAt).toLocaleString()}

, h2: ({ node, ...props }) =>

, h3: ({ node, ...props }) =>

, h4: ({ node, ...props }) =>

, h5: ({ node, ...props }) =>

, p: ({ node, ...props }) =>

, img: ({ node, ...props }) => , th: ({ node, ...props }) => , td: ({ node, ...props }) => , table: ({ node, ...props }) =>

, pre: ({ node, ...props }) =>
,
                            blockquote: ({ node, ...props }) => 
, }} /> )} ) }