Skip to content

Commit

Permalink
feat(next-drupal): add NextDrupal and NextDrupalFetch class definitions
Browse files Browse the repository at this point in the history
The DrupalClient class has been refactored to inherit from the NextDrupalFetch
(base class) and NextDrupal (JsonAPI/App Router class). DrupalClient class
contains the methods that are only needed to support Next.js' Pages Router.

The getPathFromContext() method has been replaced with the
constructPathFromSegment() method for App Router usages.

Issue #665
  • Loading branch information
JohnAlbin committed Mar 7, 2024
1 parent a49f641 commit 3796ef2
Show file tree
Hide file tree
Showing 31 changed files with 3,962 additions and 3,456 deletions.
1,514 changes: 0 additions & 1,514 deletions packages/next-drupal/src/client.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/next-drupal/src/draft-constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const DRAFT_DATA_COOKIE_NAME = "next_drupal_draft_data"

// See https://vercel.com/docs/workflow-collaboration/draft-mode
export const DRAFT_MODE_COOKIE_NAME = "__prerender_bypass"
9 changes: 6 additions & 3 deletions packages/next-drupal/src/draft.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { cookies, draftMode } from "next/headers"
import { redirect } from "next/navigation"
import { DRAFT_DATA_COOKIE_NAME, DRAFT_MODE_COOKIE_NAME } from "./client"
import {
DRAFT_DATA_COOKIE_NAME,
DRAFT_MODE_COOKIE_NAME,
} from "./draft-constants"
import type { NextRequest } from "next/server"
import type { DrupalClient } from "./client"
import type { NextDrupal } from "./next-drupal"

export async function enableDraftMode(
request: NextRequest,
drupal: DrupalClient
drupal: NextDrupal
): Promise<Response | never> {
// Validate the draft request.
const response = await drupal.validateDraftUrl(request.nextUrl.searchParams)
Expand Down
Loading

0 comments on commit 3796ef2

Please sign in to comment.