-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use
defineEnableDraftMode
(#523)
- Loading branch information
Showing
10 changed files
with
31 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { draftMode } from 'next/headers' | ||
import { redirect } from 'next/navigation' | ||
|
||
export async function GET() { | ||
;(await draftMode()).disable() | ||
|
||
redirect('/') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { apiVersion, dataset, projectId } from 'lib/sanity.api' | ||
import { createClient } from 'next-sanity' | ||
import { defineEnableDraftMode } from 'next-sanity/draft-mode' | ||
|
||
const token = process.env.SANITY_API_READ_TOKEN | ||
if (!token) { | ||
throw new Error( | ||
'A secret is provided but there is no `SANITY_API_READ_TOKEN` environment variable setup.', | ||
) | ||
} | ||
const client = createClient({ | ||
projectId, | ||
dataset, | ||
apiVersion, | ||
useCdn: false, | ||
token, | ||
}) | ||
|
||
export const { GET } = defineEnableDraftMode({ client }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters