File tree 7 files changed +59
-39
lines changed
next-app-router/app/api/draft
7 files changed +59
-39
lines changed Original file line number Diff line number Diff line change 1
- import { redirect } from 'next/navigation'
1
+ import { defineEnableDraftMode } from 'next-sanity/draft-mode'
2
+ import { client } from '../../sanity.client'
3
+ import { token } from '../../sanity.fetch'
2
4
3
- import { draftMode } from 'next/headers'
4
-
5
- export async function GET ( request : Request ) {
6
- ; ( await draftMode ( ) ) . enable ( )
7
- redirect ( '/' )
8
- }
5
+ export const { GET } = defineEnableDraftMode ( {
6
+ client : client . withConfig ( { token} ) ,
7
+ } )
Original file line number Diff line number Diff line change 1
1
/// <reference types="next" />
2
2
/// <reference types="next/image-types/global" />
3
+ /// <reference types="next/navigation-types/compat/navigation" />
3
4
4
5
// NOTE: This file should not be edited
5
- // see https://nextjs.org/docs/pages /api-reference/config/typescript for more information.
6
+ // see https://nextjs.org/docs/app /api-reference/config/typescript for more information.
Original file line number Diff line number Diff line change 19
19
"groq" : " 3.71.0" ,
20
20
"groqd" : " 0.15.12" ,
21
21
"next" : " 15.1.6" ,
22
+ "next-sanity" : " 9.8.39" ,
22
23
"react" : " 19.0.0" ,
23
24
"react-dom" : " 19.0.0" ,
24
25
"ui" : " workspace:*"
Original file line number Diff line number Diff line change
1
+ import { defineEnableDraftMode } from 'next-sanity/draft-mode'
2
+ import { client } from '../../../sanity.client'
3
+ import { token } from '../../../sanity.fetch'
4
+
5
+ export const { GET } = defineEnableDraftMode ( {
6
+ client : client . withConfig ( { token} ) ,
7
+ } )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 89
89
"mendoza" : " 3.0.8"
90
90
},
91
91
"devDependencies" : {
92
- "@sanity/client" : " ^6.25 .0" ,
92
+ "@sanity/client" : " ^6.27 .0" ,
93
93
"@sanity/pkg-utils" : " 7.0.2" ,
94
94
"@sanity/prettier-config" : " ^1.0.3" ,
95
95
"@sanity/semantic-release-preset" : " ^5.0.0" ,
120
120
"vitest-github-actions-reporter" : " ^0.11.1"
121
121
},
122
122
"peerDependencies" : {
123
- "@sanity/client" : " ^6.25 .0" ,
123
+ "@sanity/client" : " ^6.27 .0" ,
124
124
"react" : " ^18.0.0 || >=19.0.0-rc"
125
125
},
126
126
"peerDependenciesMeta" : {
You can’t perform that action at this time.
0 commit comments