Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/example-router-migration/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ async function getNode(slug: string[]) {

const params: JsonApiParams = {}

const isDraftMode = draftMode().isEnabled
const draftData = getDraftData()

if (draftData.path === path) {
params.resourceVersion = draftData.resourceVersion
}

// Translating the path also allows us to discover the entity type.
const translatedPath = await drupal.translatePath(path)
const translatedPath = await drupal.translatePath(path, {
withAuth: isDraftMode,
})

if (!translatedPath) {
throw new Error("Resource not found", { cause: "NotFound" })
Expand All @@ -34,6 +37,7 @@ async function getNode(slug: string[]) {

const resource = await drupal.getResource<DrupalNode>(type, uuid, {
params,
withAuth: isDraftMode,
})

if (!resource) {
Expand Down
6 changes: 5 additions & 1 deletion starters/basic-starter/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ async function getNode(slug: string[]) {

const params: JsonApiParams = {}

const isDraftMode = draftMode().isEnabled
const draftData = getDraftData()

if (draftData.path === path) {
params.resourceVersion = draftData.resourceVersion
}

// Translating the path also allows us to discover the entity type.
const translatedPath = await drupal.translatePath(path)
const translatedPath = await drupal.translatePath(path, {
withAuth: isDraftMode,
})

if (!translatedPath) {
throw new Error("Resource not found", { cause: "NotFound" })
Expand All @@ -34,6 +37,7 @@ async function getNode(slug: string[]) {

const resource = await drupal.getResource<DrupalNode>(type, uuid, {
params,
withAuth: isDraftMode,
})

if (!resource) {
Expand Down