feat: support Cache Components#114
Conversation
# Conflicts: # package-lock.json # package.json # src/index.ts
|
Two additions to round out the preview story for Cache Components: 1. Add
// page.tsx
const page = await fetchPage(uid, await getPreviewRef());
// fetchPage keeps "use cache" + cacheLife + cacheTagPrismicPages in userland — untouched2. Clear Both keep |
Add `getPreviewRef`, the read-side counterpart to `redirectToPreviewURL`, for passing the preview ref into a cached function under Cache Components. `enableAutoPreviews` now delegates to it so the read logic stays in sync. `exitPreview` now clears the Prismic preview cookie, closing the preview-cookie loop (write -> read -> clear). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a Next.js app with Cache Components enabled to exercise `cacheTagPrismicPages`, `revalidatePrismicPages`, and `getPreviewRef` end to end, plus a spec covering tag-based revalidation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Statically generate pages with `generateStaticParams` and read the repository name from disk so the page is fully static, matching a typical Prismic site and how the cache helpers are used in practice. Adopt the reference app's `fetchPage` shape (conditional `cacheLife`, `notFound` fallback) and a webhook-shaped revalidate route. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolves: N/A
Description
This PR adds support for Cache Components using three new APIs:
cacheTagPrismicPages()- CallscacheTagfor Prismic pages and their dependent pages.revalidatePrismicPages()- CallsrevalidateTagfor Prismic pages.getPrismicCacheTags()- Converts a list of Prismic pages to cache tags. Used bycacheTagPrismicPages().Cache tags are formatted as
prismic/${id}, whereidis a Prismic page's ID. With the above APIs, developers shouldn't be writing cache tags manually for Prismic pages.Checklist
Preview
Tagging a page:
Revalidating changed pages:
How to QA 1
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩