mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(global) compatibility milestone
This commit is contained in:
19 files changed
+347
-119
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import PostList from '@/app/(pages)/blog/PostList';
|
||||
import Pagination from '@/app/(pages)/blog/Pagination';
|
||||
import { fetchNocturneApi } from '@/app/(pages)/blog/api';
|
||||
import { fetchPostListPagination } from '@/src/api/blog/post';
|
||||
|
||||
|
||||
async function Blog({
|
||||
searchParams
|
||||
@@ -10,15 +11,34 @@ async function Blog({
|
||||
|
||||
const parsePage = Number((await searchParams)?.page);
|
||||
const currPage = parsePage > 0 ? parsePage : 1;
|
||||
const ret = await fetchNocturneApi(`/blog/get_page_count`);
|
||||
const pageCount = (await ret.json() as any)['res'] as number;
|
||||
|
||||
return (
|
||||
<div className={ 'w-full min-w-full space-y-4' }>
|
||||
<PostList page={ currPage } />
|
||||
<Pagination total={ pageCount } />
|
||||
</div>
|
||||
);
|
||||
|
||||
try {
|
||||
const pagination = await fetchPostListPagination();
|
||||
const pageCount = pagination.data.page_count;
|
||||
|
||||
return (
|
||||
<div className={ 'w-full min-w-full space-y-4' }>
|
||||
<PostList page={ currPage } />
|
||||
<Pagination total={ pageCount } />
|
||||
</div>
|
||||
);
|
||||
} catch (e: any) {
|
||||
return (
|
||||
<div className={ `flex h-full min-h-dvh w-full justify-center items-center` }>
|
||||
<div className={ `flex-row` }>
|
||||
<p className={ `text-xl font-bold` }>
|
||||
{ 'Unexpected Error [loading pagination]:' }
|
||||
</p>
|
||||
<p className={ `font-bold` }>
|
||||
{ e.message }
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default Blog;
|
||||
Reference in new issue
Block a user