File tree Expand file tree Collapse file tree 6 files changed +107
-0
lines changed
tests/fixtures/dynamic-cms-responses Expand file tree Collapse file tree 6 files changed +107
-0
lines changed Original file line number Diff line number Diff line change 1+ import { getDeployStore } from '@netlify/blobs'
2+ import { Context } from '@netlify/functions'
3+
4+ // publish or unpublish "cms content" depending on the sent operation
5+ export default async function handler ( _request : Request , context : Context ) {
6+ const store = getDeployStore ( { name : 'cms-content' , consistency : 'strong' } )
7+ const BLOB_KEY = 'key'
8+
9+ const operation = context . params [ 'operation' ]
10+
11+ if ( operation === 'publish' ) {
12+ await store . setJSON ( BLOB_KEY , { content : true } )
13+ }
14+
15+ if ( operation === 'unpublish' ) {
16+ await store . delete ( BLOB_KEY )
17+ }
18+
19+ return Response . json ( { ok : true } )
20+ }
21+
22+ export const config = {
23+ path : '/cms/:operation' ,
24+ }
Original file line number Diff line number Diff line change 1+ /** @type {import('next').NextConfig } */
2+ const nextConfig = {
3+ output : 'standalone' ,
4+ eslint : {
5+ ignoreDuringBuilds : true ,
6+ } ,
7+ generateBuildId : ( ) => 'build-id' ,
8+ }
9+
10+ module . exports = nextConfig
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " page-router" ,
3+ "version" : " 0.1.0" ,
4+ "private" : true ,
5+ "scripts" : {
6+ "postinstall" : " next build" ,
7+ "dev" : " next dev" ,
8+ "build" : " next build"
9+ },
10+ "dependencies" : {
11+ "@netlify/blobs" : " ^8.1.0" ,
12+ "@netlify/functions" : " ^2.7.0" ,
13+ "@netlify/plugin-nextjs" : " ^5.10.1" ,
14+ "netlify-cli" : " ^19.0.3" ,
15+ "next" : " latest" ,
16+ "react" : " 18.2.0" ,
17+ "react-dom" : " 18.2.0"
18+ },
19+ "devDependencies" : {
20+ "@types/node" : " 22.13.13" ,
21+ "@types/react" : " 19.0.12" ,
22+ "typescript" : " 5.8.2"
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ export default function NotFound ( ) {
2+ return < p > Custom 404 page</ p >
3+ }
Original file line number Diff line number Diff line change 1+ export default async function handler ( req , res ) {
2+ try {
3+ const pathToPurge = req . query . path ?? '/static/revalidate-manual'
4+ await res . revalidate ( pathToPurge )
5+ return res . json ( { code : 200 , message : 'success' } )
6+ } catch ( err ) {
7+ return res . status ( 500 ) . send ( { code : 500 , message : err . message } )
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ import { getDeployStore } from '@netlify/blobs'
2+
3+ const Content = ( { value } ) => (
4+ < div >
5+ < p >
6+ < span > { JSON . stringify ( value ) } </ span >
7+ </ p >
8+ </ div >
9+ )
10+
11+ export async function getStaticProps ( ) {
12+ const store = getDeployStore ( { name : 'cms-content' , consistency : 'strong' } )
13+ const BLOB_KEY = 'key'
14+
15+ const value = await store . get ( BLOB_KEY , { type : 'json' } )
16+
17+ if ( ! value ) {
18+ return {
19+ notFound : true ,
20+ }
21+ }
22+
23+ return {
24+ props : {
25+ value : value
26+ } ,
27+ }
28+ }
29+
30+ export const getStaticPaths = ( ) => {
31+ return {
32+ paths : [ ] ,
33+ fallback : 'blocking' , // false or "blocking"
34+ }
35+ }
36+
37+ export default Content
You can’t perform that action at this time.
0 commit comments