feat(blog) fix style

This commit is contained in:
lumither committed 2024-05-29 18:35:53 +08:00
1 parent bfee26609e
commit b4007b6c6e
5 files changed
+18 -15

No files matched your search

+1 -3
View File
@@ -19,13 +19,11 @@ function BlogPostCard({ post }: Props) {
let post_id = (post as any)['post_id']; let post_id = (post as any)['post_id'];
let header_img = (post as any)['header_img']; let header_img = (post as any)['header_img'];
console.log(header_img);
return ( return (
<div className={ `w-full` }> <div className={ `w-full` }>
<Card as={ Link } href={ `/blog/post/${ post_id }` } <Card as={ Link } href={ `/blog/post/${ post_id }` }
className={ `mx-7 group` } className={ `group` }
isPressable isPressable
isHoverable isHoverable
> >
+1 -1
View File
@@ -6,7 +6,7 @@ function Layout({
children: React.ReactNode; children: React.ReactNode;
}) { }) {
return ( return (
<div className={ 'flex items-stretch justify-center' }> <div className={ 'flex flex-auto p-7 items-stretch justify-center' }>
{ children } { children }
</div> </div>
); );
+8 -6
View File
@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import fetch_posts_list from '@/app/blog/fetch_posts_list'; import fetch_posts_list from '@/app/blog/fetch_posts_list';
import BlogPostCard from '@/app/blog/BlogPostCard'; import BlogPostCard from '@/app/blog/BlogPostCard';
import { Card, CardBody } from '@nextui-org/card';
async function Blog() { async function Blog() {
@@ -9,9 +10,9 @@ async function Blog() {
let posts = res['posts']; let posts = res['posts'];
return ( return (
// blog list // blog list
<ul className={ 'flex flex-col items-center w-full' }> <ul className={ 'flex flex-col items-center w-full space-y-7' }>
{ posts.map((post: JSON, key: React.Key | null | undefined) => ( { posts.map((post: JSON, key: React.Key | null | undefined) => (
<li key={ key } className={ 'my-7 w-full' }> <li key={ key } className={ 'w-full' }>
<BlogPostCard post={ post } /> <BlogPostCard post={ post } />
</li>) </li>)
) } ) }
@@ -19,10 +20,11 @@ async function Blog() {
); );
} catch (e: any) { } catch (e: any) {
return ( return (
<> <Card className={ `w-full` }>
{ e.toString() } <CardBody>
</> Fatal: Failed to load post list.
); </CardBody>
</Card>);
} }
} }
+7 -4
View File
@@ -16,8 +16,11 @@ type Props = {
} }
async function Generate(props: Props) { async function Generate(props: Props) {
const response = await axios(`http://localhost:${ process.env.BACKEND_PORT }/api/get/post/${ props.id }`);
if (response.status !== 200) { let response: any;
try {
response = await axios(`http://localhost:${ process.env.BACKEND_PORT }/api/get/post/${ props.id }`);
} catch (e) {
return ( return (
<Card className={ `w-full` }> <Card className={ `w-full` }>
<CardBody> <CardBody>
@@ -27,6 +30,7 @@ async function Generate(props: Props) {
); );
} }
let post_data = response.data; let post_data = response.data;
return ( return (
@@ -34,12 +38,11 @@ async function Generate(props: Props) {
<Card className={ `w-full` }> <Card className={ `w-full` }>
<CardBody> <CardBody>
<Markdown <Markdown
className={ `mx-5 my-5 max-w-none prose dark:prose-invert sm:prose-sm md:prose-md lg:prose-lg` } className={ `p-5 max-w-prose text-justify text-pretty会 prose prose-sm dark:prose-invert md:prose-md lg:prose-lg` }
remarkPlugins={ [ remarkGfm, remarkToc, remarkFrontmatter ] } remarkPlugins={ [ remarkGfm, remarkToc, remarkFrontmatter ] }
rehypePlugins={ [ rehypeHighlight, rehypeRaw, rehypeSanitize ] } rehypePlugins={ [ rehypeHighlight, rehypeRaw, rehypeSanitize ] }
>{ (post_data as any)['content'] }</Markdown> >{ (post_data as any)['content'] }</Markdown>
</CardBody> </CardBody>
</Card> </Card>
</div> </div>
); );
+1 -1
View File
@@ -33,7 +33,7 @@ function ThemeSwitcher() {
} }
} } } }
></Switch> ></Switch>
<p className={ `font-bold` }>{ `Toggle Theme` }</p> <p className={ `font-bold hidden md:block` }>{ `Toggle Theme` }</p>
</div> </div>
</div> </div>
); );