File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
examples/playground/app/isr/[id] Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ // Imported from https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration
2+ interface Post {
3+ id : string ;
4+ title : string ;
5+ content : string ;
6+ }
7+
8+ // Next.js will invalidate the cache when a
9+ // request comes in, at most once every 1 hour.
10+ export const revalidate = 3600 ;
11+
12+ // We'll prerender only the params from `generateStaticParams` at build time.
13+ // If a request comes in for a path that hasn't been generated,
14+ // Next.js will server-render the page on-demand.
15+ export const dynamicParams = false ; // or false, to 404 on unknown paths
16+
17+ export async function generateStaticParams ( ) {
18+ return [ { id : "1" } , { id : "2" } , { id : "3" } ] ;
19+ }
20+
21+ export default async function Page ( { params } : { params : Promise < { id : string } > } ) {
22+ const id = ( await params ) . id ;
23+ const post : Post = await fetch ( `https://api.vercel.app/blog/${ id } ` ) . then ( ( res ) => res . json ( ) ) ;
24+ return (
25+ < main >
26+ < h1 > { post . title } </ h1 >
27+ < p > { post . content } </ p >
28+ </ main >
29+ ) ;
30+ }
You can’t perform that action at this time.
0 commit comments