mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 11:06:23 +00:00
✨ feat: enhance post retrieval with authorization token
- Updated `getPostById` function to accept an optional authorization token. - Modified `PostPage` to retrieve the token from cookies and pass it to the API call. - Added smooth transition effects for background and text colors in `globals.css`. - Cleaned up imports and formatting in `blog-home.tsx`. - Refactored `blog-post.tsx` to use `MDXRemote` for rendering markdown content. - Introduced `blog-comment.tsx` and `blog-post-header.client.tsx` components for better structure. - Added a switch component for dark/light mode toggle in the navbar. - Updated `Post` model to include a description field.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { getPostById } from '@/api/post'
|
||||
import { cookies } from 'next/headers'
|
||||
import BlogPost from '@/components/blog-post'
|
||||
|
||||
interface Props {
|
||||
@ -6,8 +7,9 @@ interface Props {
|
||||
}
|
||||
|
||||
export default async function PostPage({ params }: Props) {
|
||||
const cookieStore = await cookies();
|
||||
const { id } = await params
|
||||
const post = await getPostById(id)
|
||||
const post = await getPostById(id, cookieStore.get('token')?.value || '');
|
||||
if (!post)
|
||||
return <div>文章不存在</div>
|
||||
return <BlogPost post={post} />
|
||||
|
@ -120,3 +120,7 @@
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
|
||||
html, body {
|
||||
transition: background-color 0.3s, color 0.3s !important;
|
||||
}
|
Reference in New Issue
Block a user