mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(blog::api) fix apis, frontend
This commit is contained in:
14 files changed
+82
-226
No files matched your search
@@ -18,7 +18,7 @@ function BlogPostCard({ post }: Props) {
|
||||
// let last_update = new Date((post as any)['last_update']);
|
||||
let first_update = new Date((post as any)['first_update']);
|
||||
let post_id = (post as any)['post_id'];
|
||||
let header_img = (post as any)['header_img'];
|
||||
let header_img = ((post as any)['header_img'] as string | null);
|
||||
|
||||
return (
|
||||
|
||||
@@ -29,7 +29,7 @@ function BlogPostCard({ post }: Props) {
|
||||
isHoverable
|
||||
>
|
||||
|
||||
{ header_img !== '' && <div className={ `w-full overflow h-80 relative` }>
|
||||
{ header_img && <div className={ `w-full overflow h-80 relative` }>
|
||||
<Image
|
||||
alt={ 'cover picture' }
|
||||
src={ header_img }
|
||||
@@ -48,7 +48,7 @@ function BlogPostCard({ post }: Props) {
|
||||
|
||||
<CardBody className={ `overflow-visible` }>
|
||||
<div className={ `flex flex-row justify-between` }>
|
||||
<div className={ `mx-2 ${ header_img !== '' ? '-mt-6' : 'mt-2' }` }>
|
||||
<div className={ `mx-2 ${ header_img ? '-mt-6' : 'mt-2' }` }>
|
||||
<Chip className={ `mb-2 z-30 text-lg` } radius={ `sm` } size={ 'lg' } color={ `secondary` }
|
||||
variant={ `solid` }>{ category }</Chip>
|
||||
<p className={ `text-4xl font-bold` }> { title }</p>
|
||||
|
||||
@@ -8,8 +8,8 @@ import { Card, CardBody } from '@nextui-org/card';
|
||||
|
||||
const PostList = async ({ page }: { page: number }) => {
|
||||
try {
|
||||
const res = await fetchNocturneApi(`/get_post_list?page=${ page }`);
|
||||
let posts = (await res.json() as any)['posts'];
|
||||
const res = await fetchNocturneApi(`/blog/get_post_list?page=${ page }`);
|
||||
const posts = await res.json();
|
||||
return (
|
||||
// blog list
|
||||
<div className={ 'w-full' }>
|
||||
|
||||
@@ -2,15 +2,15 @@ import PostList from '@/app/blog/PostList';
|
||||
import Pagination from '@/app/blog/Pagination';
|
||||
import { fetchNocturneApi } from '@/app/blog/api';
|
||||
|
||||
async function Blog({ searchParams }: {
|
||||
searchParams?: {
|
||||
page?: number
|
||||
};
|
||||
async function Blog({
|
||||
searchParams
|
||||
}: {
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
|
||||
}) {
|
||||
|
||||
const parsePage = Number(searchParams?.page);
|
||||
const parsePage = Number((await searchParams)?.page);
|
||||
const currPage = parsePage > 0 ? parsePage : 1;
|
||||
const ret = await fetchNocturneApi(`/get_page_count`);
|
||||
const ret = await fetchNocturneApi(`/blog/get_page_count`);
|
||||
const pageCount = (await ret.json() as any)['res'] as number;
|
||||
|
||||
return (
|
||||
|
||||
@@ -18,11 +18,11 @@ const Headers = (props: Props) => {
|
||||
// let last_update = new Date((post as any)['last_update']);
|
||||
let first_update = new Date(post['first_update']);
|
||||
// let post_id = (post as any)['post_id'];
|
||||
let header_img = post['header_img'];
|
||||
let header_img = post['meta']['header_img'] as string | null;
|
||||
|
||||
return (
|
||||
<>
|
||||
{ header_img !== '' && <div className={ `w-full overflow h-96 relative` }>
|
||||
{ header_img && <div className={ `w-full overflow h-96 relative` }>
|
||||
<Image
|
||||
alt={ 'cover picture' }
|
||||
src={ header_img }
|
||||
@@ -38,11 +38,11 @@ const Headers = (props: Props) => {
|
||||
</div> }
|
||||
|
||||
<div
|
||||
className={ header_img !== '' ?
|
||||
className={ header_img ?
|
||||
'mx-8 -mt-16 backdrop-blur transition bg-zinc-300/80 dark:bg-gray-600/25 rounded-2xl z-30'
|
||||
: 'mx-6 mt-6'
|
||||
}>
|
||||
<div className={ header_img !== '' ? `p-4` : 'p-4 pt-2' }>
|
||||
<div className={ header_img ? `p-4` : 'p-4 pt-2' }>
|
||||
<Chip className={ `mb-2` } radius={ `sm` } color={ `secondary` }
|
||||
variant={ `solid` }>{ category }</Chip>
|
||||
<p className={ `text-4xl font-bold` }> { title }</p>
|
||||
|
||||
@@ -13,7 +13,7 @@ async function PostCard(props: Props) {
|
||||
|
||||
|
||||
try {
|
||||
const res = await fetchNocturneApi(`/get_post/${ props.id }`);
|
||||
const res = await fetchNocturneApi(`/blog/get_post/${ props.id }`);
|
||||
const ret: any = await res.json();
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -3,7 +3,11 @@ import PostCard from '@/app/blog/post/[id]/PostCard';
|
||||
import { MotionDiv } from '@/app/public/MotionDiv';
|
||||
import ButtonGoBack from '@/app/blog/post/[id]/ButtonGoBack';
|
||||
|
||||
function BlogReader({ params }: { params: { id: string } }) {
|
||||
async function BlogReader({
|
||||
params
|
||||
}: {
|
||||
params: Promise<{ id: string }>
|
||||
}) {
|
||||
|
||||
return (
|
||||
<MotionDiv
|
||||
@@ -13,7 +17,7 @@ function BlogReader({ params }: { params: { id: string } }) {
|
||||
transition={ { ease: 'easeInOut', duration: 0.5 } }
|
||||
>
|
||||
<div className={ `max-w-full` }>
|
||||
<PostCard id={ params.id } />
|
||||
<PostCard id={ (await params).id } />
|
||||
</div>
|
||||
<div className={ 'mt-3' }>
|
||||
<ButtonGoBack />
|
||||
|
||||
Reference in new issue
Block a user