@prismicio/next
Version:
Helpers to integrate Prismic into Next.js apps
1 lines • 1.15 kB
Source Map (JSON)
{"version":3,"file":"enableAutoPreviews.cjs","names":["getPreviewRef"],"sources":["../src/enableAutoPreviews.ts"],"sourcesContent":["import type { Client } from \"@prismicio/client\"\n\nimport { getPreviewRef } from \"./getPreviewRef\"\n\n/** Configuration for `enableAutoPreviews`. */\nexport type EnableAutoPreviewsConfig = {\n\t/** Prismic client with which automatic previews will be enabled. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"queryContentFromRef\" | \"enableAutoPreviewsFromReq\">\n}\n\n/**\n * Configures a Prismic client to automatically query draft content during a preview session.\n *\n * @param config - Configuration for the function.\n */\nexport function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {\n\t// We use a function value so the cookie is checked on every\n\t// request. We don't have a static value to read from.\n\tconfig.client.queryContentFromRef(() => getPreviewRef())\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,mBAAmB,QAAwC;AAG1E,QAAO,OAAO,0BAA0BA,sBAAAA,eAAe,CAAC"}