-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): migrate blocks page to app router (#537)
- Loading branch information
1 parent
63c361c
commit 46c2b7c
Showing
9 changed files
with
133 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { appUrl } from '@/utils/app/config'; | ||
import { Metadata } from 'next'; | ||
import { unstable_setRequestLocale } from 'next-intl/server'; | ||
|
||
const network = process.env.NEXT_PUBLIC_NETWORK_ID; | ||
const ogUrl = process.env.NEXT_PUBLIC_OG_URL; | ||
|
||
export async function generateMetadata({ | ||
params: { hash, locale }, | ||
}: { | ||
params: { hash: string; locale: string }; | ||
}): Promise<Metadata> { | ||
unstable_setRequestLocale(locale); | ||
|
||
const metaTitle = 'Latest Near Protocol Blocks'; | ||
const metaDescription = | ||
'All Near (Ⓝ Blocks that are included in Near blockchain. The timestamp, author, gas used, gas price and included transactions are shown.'; | ||
|
||
const ogImageUrl = `${ogUrl}/api/og?basic=true&title=${encodeURIComponent( | ||
metaTitle, | ||
)}`; | ||
|
||
return { | ||
title: `${network === 'testnet' ? 'TESTNET' : ''} ${metaTitle}`, | ||
description: metaDescription, | ||
openGraph: { | ||
title: metaTitle, | ||
description: metaDescription, | ||
images: [ | ||
{ | ||
url: ogImageUrl.toString(), | ||
width: 720, | ||
height: 405, | ||
alt: metaTitle, | ||
}, | ||
], | ||
}, | ||
alternates: { | ||
canonical: `${appUrl}/blocks/${hash}`, | ||
}, | ||
}; | ||
} | ||
|
||
export default async function HashLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
params: any; | ||
}) { | ||
return <>{children}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import ListSkeleton from '@/components/app/skeleton/blocks/list'; | ||
import Skeleton from '@/components/app/skeleton/common/Skeleton'; | ||
|
||
export default function Loading() { | ||
return ( | ||
<> | ||
<div className="bg-hero-pattern dark:bg-hero-pattern-dark h-72"> | ||
<div className="container mx-auto px-3"> | ||
<h1 className="mb-4 pt-8 sm:!text-2xl text-xl text-white"> | ||
Latest Near Protocol Blocks | ||
</h1> | ||
</div> | ||
</div> | ||
<div className="container mx-auto px-3 -mt-48"> | ||
<div className="relative block lg:flex lg:space-x-2"> | ||
<div className="w-full"> | ||
<div className="bg-white dark:bg-black-600 dark:border-black-200 border soft-shadow rounded-xl pb-1"> | ||
<div className="pl-6 max-w-lg w-full py-5"> | ||
<Skeleton className="pl-6 max-w-sm leading-7 h-4" /> | ||
</div> | ||
<ListSkeleton /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="py-8"></div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import List from '@/components/app/Blocks/List'; | ||
import ListSkeleton from '@/components/app/skeleton/blocks/list'; | ||
import { Suspense } from 'react'; | ||
import { getRequest } from '@/utils/app/api'; | ||
import { getTranslations } from 'next-intl/server'; | ||
|
||
export default async function Blocks({ | ||
params: { locale }, | ||
searchParams, | ||
}: { | ||
params: { locale: string }; | ||
searchParams: { cursor?: string }; | ||
}) { | ||
const data = await getRequest('blocks', { cursor: searchParams?.cursor }); | ||
const dataCount = await getRequest('blocks/count'); | ||
const t = await getTranslations({ locale }); | ||
|
||
return ( | ||
<> | ||
<div className="bg-hero-pattern dark:bg-hero-pattern-dark h-72"> | ||
<div className="container mx-auto px-3"> | ||
<h1 className="mb-4 pt-8 sm:!text-2xl text-xl text-white"> | ||
{t('blockHeading') || 'Latest Near Protocol Blocks'} | ||
</h1> | ||
</div> | ||
</div> | ||
<div className="container mx-auto px-3 -mt-48"> | ||
<div className="relative block lg:flex lg:space-x-2"> | ||
<div className="w-full"> | ||
<Suspense fallback={<ListSkeleton />}> | ||
<List | ||
data={data} | ||
totalCount={dataCount} | ||
apiUrl={'blocks'} | ||
error={!data} | ||
/> | ||
</Suspense> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="py-8"></div> | ||
</> | ||
); | ||
} | ||
|
||
export const revalidate = 20; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.