'use client'; import { BlogApi } from "@/lib/api"; import { base62 } from "@/lib/utils"; import { useParams, useSearchParams } 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' import { PhotoProvider, PhotoView } from 'react-photo-view'; import 'react-photo-view/dist/react-photo-view.css'; import rehypeRaw from 'rehype-raw' import { Skeleton } from "@/components/ui/skeleton"; import { BlogComments } from "./components/BlogComments"; import Image from "next/image"; export default function Blog() { const params = useParams(); const searchParams = useSearchParams(); 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 password = searchParams.get('p'); const { data, error, isLoading } = useSWR( `/api/blog/${id}`, () => BlogApi.get(id, { password: password || undefined, }), ) return (
发布于:{new Date(data.createdAt).toLocaleString()}