Skip to content

Commit

Permalink
feat: use defineEnableDraftMode (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan authored Oct 22, 2024
1 parent e6d08d7 commit 6896471
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 46 deletions.
8 changes: 0 additions & 8 deletions app/api/disable-draft/route.ts

This file was deleted.

8 changes: 8 additions & 0 deletions app/api/draft-mode/enable/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineEnableDraftMode } from 'next-sanity/draft-mode'

import { client } from '@/sanity/lib/client'
import { token } from '@/sanity/lib/token'

export const { GET } = defineEnableDraftMode({
client: client.withConfig({ token }),
})
22 changes: 0 additions & 22 deletions app/api/draft/route.ts

This file was deleted.

15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
"@sanity/demo": "2.0.0",
"@sanity/icons": "3.4.0",
"@sanity/image-url": "1.0.2",
"@sanity/preview-url-secret": "2.0.0",
"@sanity/react-loader": "1.10.10",
"@sanity/ui": "2.8.9",
"@sanity/vision": "3.61.0",
"@tailwindcss/typography": "0.5.15",
"classnames": "2.5.1",
"date-fns": "4.1.0",
"next": "14.2.15",
"next-sanity": "9.5.6",
"next-sanity": "9.6.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"rxjs": "7.8.1",
Expand Down
6 changes: 0 additions & 6 deletions sanity/loader/LiveVisualEditing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ const stegaClient = client.withConfig({ stega: true })

export default function LiveVisualEditing() {
useLiveMode({ client: stegaClient })
useEffect(() => {
// If not an iframe or a Vercel Preview deployment, turn off Draft Mode
if (process.env.NEXT_PUBLIC_VERCEL_ENV !== 'preview' && window === parent) {
location.href = '/api/disable-draft'
}
}, [])

return <VisualEditing />
}

0 comments on commit 6896471

Please sign in to comment.