Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache options to getResource/getResourceCollection calls in basic starter page templates #816

Merged
merged 6 commits into from
Nov 8, 2024
Merged
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: 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
Loading