Added preview functionality for pages

This commit is contained in:
Henrik Larsson
2023-08-15 09:10:12 +02:00
parent e567914192
commit 15568378f5
7 changed files with 62 additions and 16 deletions

View File

@@ -3,7 +3,7 @@ import { draftMode } from 'next/headers'
export async function GET(request: Request) {
const { searchParams } = new URL(request.url)
const secret = searchParams.get('secret')
// const slug = searchParams.get('slug')
const slug = searchParams.get('slug')
const type = searchParams.get('type')
const locale = searchParams.get('locale')
@@ -15,7 +15,6 @@ export async function GET(request: Request) {
draftMode().enable()
if (type === 'home') {
return new Response(null, {
status: 307,
@@ -24,4 +23,13 @@ export async function GET(request: Request) {
},
})
}
if (type === 'page') {
return new Response(null, {
status: 307,
headers: {
Location: `/${locale}${slug}`,
},
})
}
}