Skip to content

Commit

Permalink
Add cache options to getResource/getResourceCollection calls in basic…
Browse files Browse the repository at this point in the history
… starter page templates (#816)
  • Loading branch information
backlineint authored Nov 8, 2024
1 parent a50598c commit bac0ee8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions starters/basic-starter/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ async function getNode(slug: string[]) {

const type = translatedPath.jsonapi?.resourceName!
const uuid = translatedPath.entity.uuid
const tag = `${translatedPath.entity.type}:${translatedPath.entity.id}`

if (type === "node--article") {
params.include = "field_image,uid"
}

const resource = await drupal.getResource<DrupalNode>(type, uuid, {
params,
next: {
revalidate: 3600,
// Replace `revalidate` with `tags` if using tag based revalidation.
// tags: [tag],
},
})

if (!resource) {
Expand Down
3 changes: 3 additions & 0 deletions starters/basic-starter/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export default async function Home() {
include: "field_image,uid",
sort: "-created",
},
next: {
revalidate: 3600,
},
}
)

Expand Down

0 comments on commit bac0ee8

Please sign in to comment.