-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
95 changed files
with
1,116 additions
and
1,054 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
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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import {NextRequest, NextResponse} from "next/server"; | ||
import {redirect} from 'next/navigation' | ||
import {redirect} from "next/navigation" | ||
import {cookies} from "next/headers"; | ||
|
||
export const revalidate = 0; | ||
|
||
export async function GET(request: NextRequest) { | ||
|
||
const secret = request.nextUrl.searchParams.get('secret') | ||
const slug = request.nextUrl.searchParams.get('slug') | ||
const secret = request.nextUrl.searchParams.get("secret") | ||
const slug = request.nextUrl.searchParams.get("slug") | ||
|
||
// Check the secret and next parameters | ||
// This secret should only be known to this route handler and the CMS | ||
if (secret !== process.env.DRUPAL_PREVIEW_SECRET) { | ||
return NextResponse.json({message: 'Invalid token'}, {status: 401}) | ||
return NextResponse.json({message: "Invalid token"}, {status: 401}) | ||
} | ||
|
||
if (!slug) { | ||
return NextResponse.json({message: 'Invalid slug path'}, {status: 401}) | ||
return NextResponse.json({message: "Invalid slug path"}, {status: 401}) | ||
} | ||
cookies().set('preview', secret, { | ||
cookies().set("preview", secret, { | ||
maxAge: 60 * 60, | ||
httpOnly: true, | ||
sameSite: 'none', | ||
sameSite: "none", | ||
secure: true, | ||
partitioned: true, | ||
}); | ||
|
||
// Redirect to the path from the fetched post | ||
// We don't redirect to searchParams.slug as that might lead to open redirect vulnerabilities | ||
redirect(`/preview/${slug}`) | ||
// We don"t redirect to searchParams.slug as that might lead to open redirect vulnerabilities | ||
redirect(`/preview${slug === "/home" ? "" : slug}`) | ||
} |
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
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
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
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,21 @@ | ||
import {isPreviewMode} from "@lib/drupal/utils"; | ||
import Editori11y from "@components/tools/editorially"; | ||
import UnpublishedBanner from "@components/elements/unpublished-banner"; | ||
|
||
const Layout = ({children}: { children: React.ReactNode }) => { | ||
const inPreview = isPreviewMode(); | ||
return ( | ||
<> | ||
{inPreview && | ||
<> | ||
<Editori11y/> | ||
<UnpublishedBanner status={false}> | ||
Preview Mode | ||
</UnpublishedBanner> | ||
</> | ||
} | ||
{children} | ||
</> | ||
) | ||
} | ||
export default Layout; |
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,10 @@ | ||
import {notFound} from "next/navigation"; | ||
import {isPreviewMode} from "@lib/drupal/utils"; | ||
import Page from "../page"; | ||
|
||
const PreviewPage = async () => { | ||
if (!isPreviewMode()) notFound(); | ||
return <Page/> | ||
} | ||
|
||
export default PreviewPage; |
Oops, something went wrong.