diff --git a/web/src/app/(main)/layout.tsx b/web/src/app/(main)/layout.tsx index 91f16d8..193cf07 100644 --- a/web/src/app/(main)/layout.tsx +++ b/web/src/app/(main)/layout.tsx @@ -14,13 +14,13 @@ export default function RootLayout({ const pathname = usePathname() return ( <> -
- -
+
+ +
+
{children}
diff --git a/web/src/app/(main)/p/[id]/page.tsx b/web/src/app/(main)/p/[id]/page.tsx index 1ef98c6..576326d 100644 --- a/web/src/app/(main)/p/[id]/page.tsx +++ b/web/src/app/(main)/p/[id]/page.tsx @@ -12,5 +12,9 @@ export default async function PostPage({ params }: Props) { const post = await getPostById(id, cookieStore.get('token')?.value || ''); if (!post) return
文章不存在
- return + return ( +
+ +
+ ) } diff --git a/web/src/components/blog-post.tsx b/web/src/components/blog-post.tsx index f172abb..b9dd520 100644 --- a/web/src/components/blog-post.tsx +++ b/web/src/components/blog-post.tsx @@ -1,7 +1,6 @@ import { Suspense } from "react"; import type { Post } from "@/models/post"; import { Calendar, Clock, FileText, Flame, Heart, MessageCircle, PenLine, SquarePen } from "lucide-react"; -import { MDXRemote } from "next-mdx-remote-client/rsc"; import ScrollToTop from "@/components/scroll-to-top.client"; import { RenderMarkdown } from "@/components/markdown"; import { isMobileByUA } from "@/utils/server/device"; @@ -134,10 +133,10 @@ async function PostContent({ post }: { post: Post }) { async function BlogPost({ post }: { post: Post }) { return ( -
- +
+ {/* */} - +
); } diff --git a/web/src/components/scroll-to-top.client.tsx b/web/src/components/scroll-to-top.client.tsx index 44c1030..450199d 100644 --- a/web/src/components/scroll-to-top.client.tsx +++ b/web/src/components/scroll-to-top.client.tsx @@ -1,9 +1,11 @@ 'use client' +import { usePathname } from "next/navigation"; import { useEffect } from "react"; export default function ScrollToTop() { + const pathname = usePathname(); useEffect(() => { window.scrollTo(0, 0); - }, []); + }, [pathname]); return null; } \ No newline at end of file