Add gists layout

This commit is contained in:
DefectingCat
2023-03-22 17:35:57 +08:00
parent 58f8d58651
commit aff25dd3ce
4 changed files with 47 additions and 33 deletions

View File

@ -1,6 +1,11 @@
import clsx from 'clsx';
import { Metadata } from 'next';
import { ReactNode } from 'react';
export const metadata: Metadata = {
title: 'RUA - Blog',
};
export default function PageLayout({ children }: { children: ReactNode }) {
return (
<main className="max-w-4xl mx-auto">

View File

@ -3,11 +3,6 @@ import PostCardLoading from './post-card-loading';
import { PostPerPage, postLists } from 'lib/posts';
import { Fragment, Suspense } from 'react';
import Pagination from 'components/rua/rua-pagination';
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'RUA - Blog',
};
export default async function Page() {
const allPosts = await postLists();

32
app/gists/layout.tsx Normal file
View File

@ -0,0 +1,32 @@
import UserInfo from './user-info';
import { ReactNode, Suspense } from 'react';
import UserInfoLoading from './user-info-skeleton';
import { Metadata } from 'next';
export const revalidate = 600;
export const metadata: Metadata = {
title: 'RUA - Gists',
};
export default async function PageLayout({
children,
}: {
children: ReactNode;
}) {
return (
<>
<main className="max-w-5xl px-4 mx-auto lg:px-0">
<div className="md:flex">
<Suspense fallback={<UserInfoLoading />}>
{/* @ts-expect-error Async Server Component */}
<UserInfo />
</Suspense>
<div className="flex-1 px-1 py-4 overflow-hidden md:pl-8">
{children}
</div>
</div>
</main>
</>
);
}

View File

@ -1,16 +1,9 @@
import { getGists } from 'lib/fetcher';
import { notFound } from 'next/navigation';
import UserInfo from './user-info';
import { Suspense } from 'react';
import Pagination from 'components/rua/rua-pagination';
import FileContent from './file-content';
import UserInfoLoading from './user-info-skeleton';
import { Metadata } from 'next';
export const revalidate = 600;
export const metadata: Metadata = {
title: 'RUA - Gists',
};
export default async function Page() {
const gists = await getGists();
@ -22,14 +15,6 @@ export default async function Page() {
return (
<>
<main className="max-w-5xl px-4 mx-auto lg:px-0">
<div className="md:flex">
<Suspense fallback={<UserInfoLoading />}>
{/* @ts-expect-error Async Server Component */}
<UserInfo />
</Suspense>
<div className="flex-1 px-1 py-4 overflow-hidden md:pl-8">
<FileContent gists={gists.gists} />
<Pagination
className="mt-4"
@ -40,9 +25,6 @@ export default async function Page() {
current={prev == null ? next - 1 : prev + 1}
total={total}
/>
</div>
</div>
</main>
</>
);
}