import { Suspense } from "react"; import type { Post } from "@/models/post"; import { Calendar, Clock, FileText, Flame, Heart, MessageCircle, PenLine, SquarePen } from "lucide-react"; import { RenderMarkdown } from "@/components/common/markdown"; import { isMobileByUA } from "@/utils/server/device"; import { calculateReadingTime } from "@/utils/common/post"; import {CommentSection} from "@/components/comment"; import { TargetType } from '../../models/types'; function PostMeta({ post }: { post: Post }) { return (
{/* 作者 */} {post.user.nickname || "未知作者"} {/* 字数 */} {post.content.length || 0} {/* 阅读时间 */} {calculateReadingTime(post.content)} 分钟 {/* 发布时间 */} {post.createdAt ? new Date(post.createdAt).toLocaleDateString("zh-CN") : ""} {/* 最后编辑时间,如果和发布时间不一样 */} {post.updatedAt && post.createdAt !== post.updatedAt && ( {new Date(post.updatedAt).toLocaleDateString("zh-CN")} )} {/* 浏览数 */} {post.viewCount || 0} {/* 点赞数 */} {post.likeCount || 0} {/* 评论数 */} {post.commentCount || 0} {/* 热度 */} {post.heat || 0}
); } async function PostHeader({ post }: { post: Post }) { const isMobile = await isMobileByUA(); return (
{/* 背景层 */} ); } async function PostContent({ post }: { post: Post }) { const markdownClass = "prose prose-lg max-w-none dark:prose-invert " + // h1-h6 "[&_h1]:scroll-m-20 [&_h1]:text-4xl [&_h1]:font-extrabold [&_h1]:tracking-tight [&_h1]:text-balance [&_h1]:mt-10 [&_h1]:mb-6 " + "[&_h2]:scroll-m-20 [&_h2]:border-b [&_h2]:pb-2 [&_h2]:text-3xl [&_h2]:font-semibold [&_h2]:tracking-tight [&_h2]:first:mt-0 [&_h2]:mt-8 [&_h2]:mb-4 " + "[&_h3]:scroll-m-20 [&_h3]:text-2xl [&_h3]:font-semibold [&_h3]:tracking-tight [&_h3]:mt-6 [&_h3]:mb-3 " + "[&_h4]:scroll-m-20 [&_h4]:text-xl [&_h4]:font-semibold [&_h4]:tracking-tight [&_h4]:mt-5 [&_h4]:mb-2 " + // p "[&_p]:leading-7 [&_p]:mt-4 [&_p]:mb-4 " + // blockquote "[&_blockquote]:border-l-4 [&_blockquote]:border-blue-400 [&_blockquote]:pl-4 [&_blockquote]:italic [&_blockquote]:my-6 [&_blockquote]:py-2 " + // code "[&_code]:bg-gray-100 [&_code]:dark:bg-gray-800 [&_code]:rounded [&_code]:px-1 [&_code]:py-0.5 [&_code]:text-sm [&_code]:font-mono " + // a "[&_a]:text-blue-600 [&_a]:hover:underline"; return (
{post.type === "html" && (
)} {post.type === "markdown" && ( )} {post.type === "text" && (
{post.content}
)}
); } async function BlogPost({ post }: { post: Post }) { return (
{/* */}
); } export default BlogPost;