Advertisement
nithinrdy

Untitled

May 14th, 2025
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // the getData function is what contains the fetch call I described above. It's wrapped in `cache` (the standard react function) to have the response be memoized.
  2.  
  3. export async function generateMetadata(
  4.   { params }: { params: Promise<{ id: string }> },
  5.   parent: ResolvingMetadata
  6. ): Promise<Metadata> {
  7.   const id = (await params).id;
  8.   const data = await getData(id);
  9.  
  10.   if ("error" in data) notFound();
  11.  
  12.   return {
  13.     // ... some metadata, opengraph stuff
  14.   };
  15. }
  16.  
  17. export default async function Page({
  18.   params,
  19.   searchParams,
  20. }: {
  21.   params: Promise<{ id: string }>;
  22.   searchParams: Promise<SearchParams>;
  23. }) {
  24.   const id = (await params).id;
  25.   const data = await getData(id);
  26.  
  27.   if ("error" in data) notFound();
  28.  
  29.  
  30.  
  31.   return (<>
  32.       //...
  33.       </>)
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement