@prismicio/next 2.2.3-pr.136.19d76d2 → 2.2.4-pr.114.37ca25f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PrismicNextLink.d.cts +3 -3
- package/dist/PrismicNextLink.d.ts +3 -3
- package/dist/cacheTagPrismicPages.cjs +11 -0
- package/dist/cacheTagPrismicPages.cjs.map +1 -0
- package/dist/cacheTagPrismicPages.d.cts +7 -0
- package/dist/cacheTagPrismicPages.d.cts.map +1 -0
- package/dist/cacheTagPrismicPages.d.ts +7 -0
- package/dist/cacheTagPrismicPages.d.ts.map +1 -0
- package/dist/cacheTagPrismicPages.js +10 -0
- package/dist/cacheTagPrismicPages.js.map +1 -0
- package/dist/exitPreview.cjs +1 -1
- package/dist/exitPreview.cjs.map +1 -1
- package/dist/exitPreview.d.cts +1 -1
- package/dist/exitPreview.d.ts +1 -1
- package/dist/exitPreview.js +1 -1
- package/dist/exitPreview.js.map +1 -1
- package/dist/getPrismicCacheTags.cjs +29 -0
- package/dist/getPrismicCacheTags.cjs.map +1 -0
- package/dist/getPrismicCacheTags.d.cts +14 -0
- package/dist/getPrismicCacheTags.d.cts.map +1 -0
- package/dist/getPrismicCacheTags.d.ts +14 -0
- package/dist/getPrismicCacheTags.d.ts.map +1 -0
- package/dist/getPrismicCacheTags.js +28 -0
- package/dist/getPrismicCacheTags.js.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/lib/devMsg.cjs +1 -1
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/pages/SliceSimulator.cjs.map +1 -1
- package/dist/pages/SliceSimulator.d.cts +1 -1
- package/dist/pages/SliceSimulator.d.ts +1 -1
- package/dist/pages/SliceSimulator.js.map +1 -1
- package/dist/pages/exitPreview.cjs +1 -1
- package/dist/pages/exitPreview.cjs.map +1 -1
- package/dist/pages/exitPreview.d.cts +1 -1
- package/dist/pages/exitPreview.d.ts +1 -1
- package/dist/pages/exitPreview.js +1 -1
- package/dist/pages/exitPreview.js.map +1 -1
- package/dist/revalidatePrismicPages.cjs +18 -0
- package/dist/revalidatePrismicPages.cjs.map +1 -0
- package/dist/revalidatePrismicPages.d.cts +12 -0
- package/dist/revalidatePrismicPages.d.cts.map +1 -0
- package/dist/revalidatePrismicPages.d.ts +12 -0
- package/dist/revalidatePrismicPages.d.ts.map +1 -0
- package/dist/revalidatePrismicPages.js +17 -0
- package/dist/revalidatePrismicPages.js.map +1 -0
- package/package.json +11 -11
- package/src/cacheTagPrismicPages.ts +8 -0
- package/src/exitPreview.ts +1 -1
- package/src/getPrismicCacheTags.ts +44 -0
- package/src/index.ts +6 -0
- package/src/lib/devMsg.ts +1 -1
- package/src/pages/SliceSimulator.tsx +1 -1
- package/src/pages/exitPreview.ts +1 -1
- package/src/revalidatePrismicPages.ts +17 -0
|
@@ -23,7 +23,7 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
|
|
|
23
23
|
});
|
|
24
24
|
declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
|
|
25
25
|
children?: React.ReactNode | undefined;
|
|
26
|
-
} & _$react.RefAttributes<HTMLAnchorElement>, "
|
|
26
|
+
} & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
27
27
|
linkResolver?: LinkResolverFunction;
|
|
28
28
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
29
29
|
} & {
|
|
@@ -32,7 +32,7 @@ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit
|
|
|
32
32
|
href?: never;
|
|
33
33
|
}, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
|
|
34
34
|
children?: React.ReactNode | undefined;
|
|
35
|
-
} & _$react.RefAttributes<HTMLAnchorElement>, "
|
|
35
|
+
} & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
36
36
|
linkResolver?: LinkResolverFunction;
|
|
37
37
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
38
38
|
} & {
|
|
@@ -41,7 +41,7 @@ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit
|
|
|
41
41
|
href?: never;
|
|
42
42
|
}, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
|
|
43
43
|
children?: React.ReactNode | undefined;
|
|
44
|
-
} & _$react.RefAttributes<HTMLAnchorElement>, "
|
|
44
|
+
} & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
45
45
|
linkResolver?: LinkResolverFunction;
|
|
46
46
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
47
47
|
} & {
|
|
@@ -23,7 +23,7 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
|
|
|
23
23
|
});
|
|
24
24
|
declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
|
|
25
25
|
children?: React.ReactNode | undefined;
|
|
26
|
-
} & _$react.RefAttributes<HTMLAnchorElement>, "
|
|
26
|
+
} & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
27
27
|
linkResolver?: LinkResolverFunction;
|
|
28
28
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
29
29
|
} & {
|
|
@@ -32,7 +32,7 @@ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit
|
|
|
32
32
|
href?: never;
|
|
33
33
|
}, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
|
|
34
34
|
children?: React.ReactNode | undefined;
|
|
35
|
-
} & _$react.RefAttributes<HTMLAnchorElement>, "
|
|
35
|
+
} & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
36
36
|
linkResolver?: LinkResolverFunction;
|
|
37
37
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
38
38
|
} & {
|
|
@@ -41,7 +41,7 @@ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit
|
|
|
41
41
|
href?: never;
|
|
42
42
|
}, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
|
|
43
43
|
children?: React.ReactNode | undefined;
|
|
44
|
-
} & _$react.RefAttributes<HTMLAnchorElement>, "
|
|
44
|
+
} & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
45
45
|
linkResolver?: LinkResolverFunction;
|
|
46
46
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
47
47
|
} & {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_getPrismicCacheTags = require("./getPrismicCacheTags.cjs");
|
|
3
|
+
let next_cache_js = require("next/cache.js");
|
|
4
|
+
//#region src/cacheTagPrismicPages.ts
|
|
5
|
+
function cacheTagPrismicPages(pages) {
|
|
6
|
+
(0, next_cache_js.cacheTag)(...require_getPrismicCacheTags.getPrismicCacheTags(pages));
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.cacheTagPrismicPages = cacheTagPrismicPages;
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=cacheTagPrismicPages.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheTagPrismicPages.cjs","names":["getPrismicCacheTags"],"sources":["../src/cacheTagPrismicPages.ts"],"sourcesContent":["import type { PrismicDocument } from \"@prismicio/client\"\nimport { cacheTag } from \"next/cache\"\n\nimport { getPrismicCacheTags } from \"./getPrismicCacheTags\"\n\nexport function cacheTagPrismicPages(pages: PrismicDocument[]): void {\n\tcacheTag(...getPrismicCacheTags(pages))\n}\n"],"mappings":";;;;AAKA,SAAgB,qBAAqB,OAAgC;AACpE,EAAA,GAAA,cAAA,UAAS,GAAGA,4BAAAA,oBAAoB,MAAM,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PrismicDocument } from "@prismicio/client";
|
|
2
|
+
|
|
3
|
+
//#region src/cacheTagPrismicPages.d.ts
|
|
4
|
+
declare function cacheTagPrismicPages(pages: PrismicDocument[]): void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { cacheTagPrismicPages };
|
|
7
|
+
//# sourceMappingURL=cacheTagPrismicPages.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheTagPrismicPages.d.cts","names":[],"sources":["../src/cacheTagPrismicPages.ts"],"mappings":";;;iBAKgB,oBAAA,CAAqB,KAAA,EAAO,eAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PrismicDocument } from "@prismicio/client";
|
|
2
|
+
|
|
3
|
+
//#region src/cacheTagPrismicPages.d.ts
|
|
4
|
+
declare function cacheTagPrismicPages(pages: PrismicDocument[]): void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { cacheTagPrismicPages };
|
|
7
|
+
//# sourceMappingURL=cacheTagPrismicPages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheTagPrismicPages.d.ts","names":[],"sources":["../src/cacheTagPrismicPages.ts"],"mappings":";;;iBAKgB,oBAAA,CAAqB,KAAA,EAAO,eAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getPrismicCacheTags } from "./getPrismicCacheTags.js";
|
|
2
|
+
import { cacheTag } from "next/cache.js";
|
|
3
|
+
//#region src/cacheTagPrismicPages.ts
|
|
4
|
+
function cacheTagPrismicPages(pages) {
|
|
5
|
+
cacheTag(...getPrismicCacheTags(pages));
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { cacheTagPrismicPages };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=cacheTagPrismicPages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheTagPrismicPages.js","names":[],"sources":["../src/cacheTagPrismicPages.ts"],"sourcesContent":["import type { PrismicDocument } from \"@prismicio/client\"\nimport { cacheTag } from \"next/cache\"\n\nimport { getPrismicCacheTags } from \"./getPrismicCacheTags\"\n\nexport function cacheTagPrismicPages(pages: PrismicDocument[]): void {\n\tcacheTag(...getPrismicCacheTags(pages))\n}\n"],"mappings":";;;AAKA,SAAgB,qBAAqB,OAAgC;AACpE,UAAS,GAAG,oBAAoB,MAAM,CAAC"}
|
package/dist/exitPreview.cjs
CHANGED
package/dist/exitPreview.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.cjs","names":[],"sources":["../src/exitPreview.ts"],"sourcesContent":["/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in a Router\n * Handler.\n *\n * @example\n * \t
|
|
1
|
+
{"version":3,"file":"exitPreview.cjs","names":[],"sources":["../src/exitPreview.ts"],"sourcesContent":["/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in a Router\n * Handler.\n *\n * @example\n * \t;```typescript\n * \t// src/app/api/exit-preview/route.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport async function GET() {\n * \t\treturn await exitPreview()\n * \t}\n * \t```\n */\nexport async function exitPreview(): Promise<Response> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\")\n\n\t;(await draftMode()).disable()\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\treturn new Response(JSON.stringify({ success: true }), {\n\t\theaders: {\n\t\t\t\"Cache-Control\": \"no-store\",\n\t\t},\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,eAAsB,cAAiC;CAItD,MAAM,EAAE,cAAc,MAAM,OAAO;AAElC,EAAC,MAAM,WAAW,EAAE,SAAS;AAG9B,QAAO,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,MAAM,CAAC,EAAE,EACtD,SAAS,EACR,iBAAiB,YACjB,EACD,CAAC"}
|
package/dist/exitPreview.d.cts
CHANGED
package/dist/exitPreview.d.ts
CHANGED
package/dist/exitPreview.js
CHANGED
package/dist/exitPreview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.js","names":[],"sources":["../src/exitPreview.ts"],"sourcesContent":["/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in a Router\n * Handler.\n *\n * @example\n * \t
|
|
1
|
+
{"version":3,"file":"exitPreview.js","names":[],"sources":["../src/exitPreview.ts"],"sourcesContent":["/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in a Router\n * Handler.\n *\n * @example\n * \t;```typescript\n * \t// src/app/api/exit-preview/route.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport async function GET() {\n * \t\treturn await exitPreview()\n * \t}\n * \t```\n */\nexport async function exitPreview(): Promise<Response> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\")\n\n\t;(await draftMode()).disable()\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\treturn new Response(JSON.stringify({ success: true }), {\n\t\theaders: {\n\t\t\t\"Cache-Control\": \"no-store\",\n\t\t},\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,eAAsB,cAAiC;CAItD,MAAM,EAAE,cAAc,MAAM,OAAO;AAElC,EAAC,MAAM,WAAW,EAAE,SAAS;AAG9B,QAAO,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,MAAM,CAAC,EAAE,EACtD,SAAS,EACR,iBAAiB,YACjB,EACD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/getPrismicCacheTags.ts
|
|
2
|
+
const CACHE_TAG_PREFIX = "prismic/";
|
|
3
|
+
/**
|
|
4
|
+
* Generates cache tags for a set of Prismic pages. Tags for linked pages (e.g. a content
|
|
5
|
+
* relationship) are included to ensure all related content can be revalidated.
|
|
6
|
+
*
|
|
7
|
+
* @param pages - A set of Prismic pages used to tag the function.
|
|
8
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
9
|
+
*/
|
|
10
|
+
function getPrismicCacheTags(pages) {
|
|
11
|
+
return [...new Set(getPrismicDocumentIDs(pages))].map((id) => buildPrismicCacheTag(id));
|
|
12
|
+
}
|
|
13
|
+
function buildPrismicCacheTag(id) {
|
|
14
|
+
return `${CACHE_TAG_PREFIX}${id}`;
|
|
15
|
+
}
|
|
16
|
+
function getPrismicDocumentIDs(input) {
|
|
17
|
+
if (typeof input !== "object" || input == null) return [];
|
|
18
|
+
if (Array.isArray(input)) return input.flatMap((item) => getPrismicDocumentIDs(item));
|
|
19
|
+
if ("id" in input && typeof input.id === "string") {
|
|
20
|
+
if ("href" in input && typeof input.href === "string" && input.href.includes("/api/v2/documents/search?") || "link_type" in input && input.link_type === "Document") if ("data" in input && typeof input.data === "object" && input.data !== null) return [input.id, ...getPrismicDocumentIDs(input.data)];
|
|
21
|
+
else return [input.id];
|
|
22
|
+
}
|
|
23
|
+
return Object.values(input).flatMap((input) => getPrismicDocumentIDs(input));
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.buildPrismicCacheTag = buildPrismicCacheTag;
|
|
27
|
+
exports.getPrismicCacheTags = getPrismicCacheTags;
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=getPrismicCacheTags.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPrismicCacheTags.cjs","names":[],"sources":["../src/getPrismicCacheTags.ts"],"sourcesContent":["import type { PrismicDocument } from \"@prismicio/client\"\n\nconst CACHE_TAG_PREFIX = \"prismic/\"\n\n/**\n * Generates cache tags for a set of Prismic pages. Tags for linked pages (e.g. a content\n * relationship) are included to ensure all related content can be revalidated.\n *\n * @param pages - A set of Prismic pages used to tag the function.\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}\n */\nexport function getPrismicCacheTags(pages: PrismicDocument[]): string[] {\n\tconst ids = [...new Set(getPrismicDocumentIDs(pages))]\n\treturn ids.map((id) => buildPrismicCacheTag(id))\n}\n\nexport function buildPrismicCacheTag(id: string): string {\n\treturn `${CACHE_TAG_PREFIX}${id}`\n}\n\nfunction getPrismicDocumentIDs(input: unknown): string[] {\n\tif (typeof input !== \"object\" || input == null) return []\n\n\tif (Array.isArray(input)) return input.flatMap((item) => getPrismicDocumentIDs(item))\n\n\tif (\"id\" in input && typeof input.id === \"string\") {\n\t\t// Document\n\t\t// Content relationship or link\n\t\tif (\n\t\t\t(\"href\" in input &&\n\t\t\t\ttypeof input.href === \"string\" &&\n\t\t\t\tinput.href.includes(\"/api/v2/documents/search?\")) ||\n\t\t\t(\"link_type\" in input && input.link_type === \"Document\")\n\t\t) {\n\t\t\tif (\"data\" in input && typeof input.data === \"object\" && input.data !== null) {\n\t\t\t\treturn [input.id, ...getPrismicDocumentIDs(input.data)]\n\t\t\t} else {\n\t\t\t\treturn [input.id]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn Object.values(input).flatMap((input) => getPrismicDocumentIDs(input))\n}\n"],"mappings":";AAEA,MAAM,mBAAmB;;;;;;;;AASzB,SAAgB,oBAAoB,OAAoC;AAEvE,QADY,CAAC,GAAG,IAAI,IAAI,sBAAsB,MAAM,CAAC,CAAC,CAC3C,KAAK,OAAO,qBAAqB,GAAG,CAAC;;AAGjD,SAAgB,qBAAqB,IAAoB;AACxD,QAAO,GAAG,mBAAmB;;AAG9B,SAAS,sBAAsB,OAA0B;AACxD,KAAI,OAAO,UAAU,YAAY,SAAS,KAAM,QAAO,EAAE;AAEzD,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,SAAS,SAAS,sBAAsB,KAAK,CAAC;AAErF,KAAI,QAAQ,SAAS,OAAO,MAAM,OAAO;MAItC,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,MAAM,KAAK,SAAS,4BAA4B,IAChD,eAAe,SAAS,MAAM,cAAc,WAE7C,KAAI,UAAU,SAAS,OAAO,MAAM,SAAS,YAAY,MAAM,SAAS,KACvE,QAAO,CAAC,MAAM,IAAI,GAAG,sBAAsB,MAAM,KAAK,CAAC;MAEvD,QAAO,CAAC,MAAM,GAAG;;AAKpB,QAAO,OAAO,OAAO,MAAM,CAAC,SAAS,UAAU,sBAAsB,MAAM,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PrismicDocument } from "@prismicio/client";
|
|
2
|
+
|
|
3
|
+
//#region src/getPrismicCacheTags.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Generates cache tags for a set of Prismic pages. Tags for linked pages (e.g. a content
|
|
6
|
+
* relationship) are included to ensure all related content can be revalidated.
|
|
7
|
+
*
|
|
8
|
+
* @param pages - A set of Prismic pages used to tag the function.
|
|
9
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
10
|
+
*/
|
|
11
|
+
declare function getPrismicCacheTags(pages: PrismicDocument[]): string[];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getPrismicCacheTags };
|
|
14
|
+
//# sourceMappingURL=getPrismicCacheTags.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPrismicCacheTags.d.cts","names":[],"sources":["../src/getPrismicCacheTags.ts"],"mappings":";;;;;AAWA;;;;;iBAAgB,mBAAA,CAAoB,KAAA,EAAO,eAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PrismicDocument } from "@prismicio/client";
|
|
2
|
+
|
|
3
|
+
//#region src/getPrismicCacheTags.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Generates cache tags for a set of Prismic pages. Tags for linked pages (e.g. a content
|
|
6
|
+
* relationship) are included to ensure all related content can be revalidated.
|
|
7
|
+
*
|
|
8
|
+
* @param pages - A set of Prismic pages used to tag the function.
|
|
9
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
10
|
+
*/
|
|
11
|
+
declare function getPrismicCacheTags(pages: PrismicDocument[]): string[];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getPrismicCacheTags };
|
|
14
|
+
//# sourceMappingURL=getPrismicCacheTags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPrismicCacheTags.d.ts","names":[],"sources":["../src/getPrismicCacheTags.ts"],"mappings":";;;;;AAWA;;;;;iBAAgB,mBAAA,CAAoB,KAAA,EAAO,eAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/getPrismicCacheTags.ts
|
|
2
|
+
const CACHE_TAG_PREFIX = "prismic/";
|
|
3
|
+
/**
|
|
4
|
+
* Generates cache tags for a set of Prismic pages. Tags for linked pages (e.g. a content
|
|
5
|
+
* relationship) are included to ensure all related content can be revalidated.
|
|
6
|
+
*
|
|
7
|
+
* @param pages - A set of Prismic pages used to tag the function.
|
|
8
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
9
|
+
*/
|
|
10
|
+
function getPrismicCacheTags(pages) {
|
|
11
|
+
return [...new Set(getPrismicDocumentIDs(pages))].map((id) => buildPrismicCacheTag(id));
|
|
12
|
+
}
|
|
13
|
+
function buildPrismicCacheTag(id) {
|
|
14
|
+
return `${CACHE_TAG_PREFIX}${id}`;
|
|
15
|
+
}
|
|
16
|
+
function getPrismicDocumentIDs(input) {
|
|
17
|
+
if (typeof input !== "object" || input == null) return [];
|
|
18
|
+
if (Array.isArray(input)) return input.flatMap((item) => getPrismicDocumentIDs(item));
|
|
19
|
+
if ("id" in input && typeof input.id === "string") {
|
|
20
|
+
if ("href" in input && typeof input.href === "string" && input.href.includes("/api/v2/documents/search?") || "link_type" in input && input.link_type === "Document") if ("data" in input && typeof input.data === "object" && input.data !== null) return [input.id, ...getPrismicDocumentIDs(input.data)];
|
|
21
|
+
else return [input.id];
|
|
22
|
+
}
|
|
23
|
+
return Object.values(input).flatMap((input) => getPrismicDocumentIDs(input));
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { buildPrismicCacheTag, getPrismicCacheTags };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=getPrismicCacheTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPrismicCacheTags.js","names":[],"sources":["../src/getPrismicCacheTags.ts"],"sourcesContent":["import type { PrismicDocument } from \"@prismicio/client\"\n\nconst CACHE_TAG_PREFIX = \"prismic/\"\n\n/**\n * Generates cache tags for a set of Prismic pages. Tags for linked pages (e.g. a content\n * relationship) are included to ensure all related content can be revalidated.\n *\n * @param pages - A set of Prismic pages used to tag the function.\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}\n */\nexport function getPrismicCacheTags(pages: PrismicDocument[]): string[] {\n\tconst ids = [...new Set(getPrismicDocumentIDs(pages))]\n\treturn ids.map((id) => buildPrismicCacheTag(id))\n}\n\nexport function buildPrismicCacheTag(id: string): string {\n\treturn `${CACHE_TAG_PREFIX}${id}`\n}\n\nfunction getPrismicDocumentIDs(input: unknown): string[] {\n\tif (typeof input !== \"object\" || input == null) return []\n\n\tif (Array.isArray(input)) return input.flatMap((item) => getPrismicDocumentIDs(item))\n\n\tif (\"id\" in input && typeof input.id === \"string\") {\n\t\t// Document\n\t\t// Content relationship or link\n\t\tif (\n\t\t\t(\"href\" in input &&\n\t\t\t\ttypeof input.href === \"string\" &&\n\t\t\t\tinput.href.includes(\"/api/v2/documents/search?\")) ||\n\t\t\t(\"link_type\" in input && input.link_type === \"Document\")\n\t\t) {\n\t\t\tif (\"data\" in input && typeof input.data === \"object\" && input.data !== null) {\n\t\t\t\treturn [input.id, ...getPrismicDocumentIDs(input.data)]\n\t\t\t} else {\n\t\t\t\treturn [input.id]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn Object.values(input).flatMap((input) => getPrismicDocumentIDs(input))\n}\n"],"mappings":";AAEA,MAAM,mBAAmB;;;;;;;;AASzB,SAAgB,oBAAoB,OAAoC;AAEvE,QADY,CAAC,GAAG,IAAI,IAAI,sBAAsB,MAAM,CAAC,CAAC,CAC3C,KAAK,OAAO,qBAAqB,GAAG,CAAC;;AAGjD,SAAgB,qBAAqB,IAAoB;AACxD,QAAO,GAAG,mBAAmB;;AAG9B,SAAS,sBAAsB,OAA0B;AACxD,KAAI,OAAO,UAAU,YAAY,SAAS,KAAM,QAAO,EAAE;AAEzD,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,SAAS,SAAS,sBAAsB,KAAK,CAAC;AAErF,KAAI,QAAQ,SAAS,OAAO,MAAM,OAAO;MAItC,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,MAAM,KAAK,SAAS,4BAA4B,IAChD,eAAe,SAAS,MAAM,cAAc,WAE7C,KAAI,UAAU,SAAS,OAAO,MAAM,SAAS,YAAY,MAAM,SAAS,KACvE,QAAO,CAAC,MAAM,IAAI,GAAG,sBAAsB,MAAM,KAAK,CAAC;MAEvD,QAAO,CAAC,MAAM,GAAG;;AAKpB,QAAO,OAAO,OAAO,MAAM,CAAC,SAAS,UAAU,sBAAsB,MAAM,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -9,13 +9,19 @@ const require_PrismicNextImage = require("./PrismicNextImage.cjs");
|
|
|
9
9
|
const require_getSlices = require("./getSlices.cjs");
|
|
10
10
|
const require_SliceSimulator = require("./SliceSimulator.cjs");
|
|
11
11
|
const require_createLocaleRedirect = require("./createLocaleRedirect.cjs");
|
|
12
|
+
const require_getPrismicCacheTags = require("./getPrismicCacheTags.cjs");
|
|
13
|
+
const require_cacheTagPrismicPages = require("./cacheTagPrismicPages.cjs");
|
|
14
|
+
const require_revalidatePrismicPages = require("./revalidatePrismicPages.cjs");
|
|
12
15
|
exports.PrismicNextImage = require_PrismicNextImage.PrismicNextImage;
|
|
13
16
|
exports.PrismicNextLink = require_PrismicNextLink.PrismicNextLink;
|
|
14
17
|
exports.PrismicPreview = require_PrismicPreview.PrismicPreview;
|
|
15
18
|
exports.SliceSimulator = require_SliceSimulator.SliceSimulator;
|
|
19
|
+
exports.cacheTagPrismicPages = require_cacheTagPrismicPages.cacheTagPrismicPages;
|
|
16
20
|
exports.createLocaleRedirect = require_createLocaleRedirect.createLocaleRedirect;
|
|
17
21
|
exports.enableAutoPreviews = require_enableAutoPreviews.enableAutoPreviews;
|
|
18
22
|
exports.exitPreview = require_exitPreview.exitPreview;
|
|
23
|
+
exports.getPrismicCacheTags = require_getPrismicCacheTags.getPrismicCacheTags;
|
|
19
24
|
exports.getSlices = require_getSlices.getSlices;
|
|
20
25
|
exports.imgixLoader = require_imgixLoader.imgixLoader;
|
|
21
26
|
exports.redirectToPreviewURL = require_redirectToPreviewURL.redirectToPreviewURL;
|
|
27
|
+
exports.revalidatePrismicPages = require_revalidatePrismicPages.revalidatePrismicPages;
|
package/dist/index.d.cts
CHANGED
|
@@ -9,4 +9,7 @@ import { SliceSimulator, SliceSimulatorParams, SliceSimulatorProps } from "./Sli
|
|
|
9
9
|
import { getSlices } from "./getSlices.cjs";
|
|
10
10
|
import { imgixLoader } from "./imgixLoader.cjs";
|
|
11
11
|
import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.cjs";
|
|
12
|
-
|
|
12
|
+
import { getPrismicCacheTags } from "./getPrismicCacheTags.cjs";
|
|
13
|
+
import { cacheTagPrismicPages } from "./cacheTagPrismicPages.cjs";
|
|
14
|
+
import { revalidatePrismicPages } from "./revalidatePrismicPages.cjs";
|
|
15
|
+
export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, PrismicNextImage, type PrismicNextImageProps, PrismicNextLink, type PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, type RedirectToPreviewURLConfig, SliceSimulator, type SliceSimulatorParams, type SliceSimulatorProps, cacheTagPrismicPages, createLocaleRedirect, enableAutoPreviews, exitPreview, getPrismicCacheTags, getSlices, imgixLoader, redirectToPreviewURL, revalidatePrismicPages };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,7 @@ import { SliceSimulator, SliceSimulatorParams, SliceSimulatorProps } from "./Sli
|
|
|
9
9
|
import { getSlices } from "./getSlices.js";
|
|
10
10
|
import { imgixLoader } from "./imgixLoader.js";
|
|
11
11
|
import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.js";
|
|
12
|
-
|
|
12
|
+
import { getPrismicCacheTags } from "./getPrismicCacheTags.js";
|
|
13
|
+
import { cacheTagPrismicPages } from "./cacheTagPrismicPages.js";
|
|
14
|
+
import { revalidatePrismicPages } from "./revalidatePrismicPages.js";
|
|
15
|
+
export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, PrismicNextImage, type PrismicNextImageProps, PrismicNextLink, type PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, type RedirectToPreviewURLConfig, SliceSimulator, type SliceSimulatorParams, type SliceSimulatorProps, cacheTagPrismicPages, createLocaleRedirect, enableAutoPreviews, exitPreview, getPrismicCacheTags, getSlices, imgixLoader, redirectToPreviewURL, revalidatePrismicPages };
|
package/dist/index.js
CHANGED
|
@@ -8,4 +8,7 @@ import { PrismicNextImage } from "./PrismicNextImage.js";
|
|
|
8
8
|
import { getSlices } from "./getSlices.js";
|
|
9
9
|
import { SliceSimulator } from "./SliceSimulator.js";
|
|
10
10
|
import { createLocaleRedirect } from "./createLocaleRedirect.js";
|
|
11
|
-
|
|
11
|
+
import { getPrismicCacheTags } from "./getPrismicCacheTags.js";
|
|
12
|
+
import { cacheTagPrismicPages } from "./cacheTagPrismicPages.js";
|
|
13
|
+
import { revalidatePrismicPages } from "./revalidatePrismicPages.js";
|
|
14
|
+
export { PrismicNextImage, PrismicNextLink, PrismicPreview, SliceSimulator, cacheTagPrismicPages, createLocaleRedirect, enableAutoPreviews, exitPreview, getPrismicCacheTags, getSlices, imgixLoader, redirectToPreviewURL, revalidatePrismicPages };
|
package/dist/lib/devMsg.cjs
CHANGED
package/dist/lib/devMsg.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.cjs","names":["version"],"sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\"\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n * \t
|
|
1
|
+
{"version":3,"file":"devMsg.cjs","names":["version"],"sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\"\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n * \t;```ts\n * \tdevMsg(\"missing-param\")\n * \t// => \"https://prismic.dev/msg/next/v1.2.3/missing-param\"\n * \t```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in the Git repository's\n * `/messages` directory.\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string): string => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,UAAU,SAAyB;AAC/C,QAAO,iCAAiCA,gBAAAA,QAAQ,GAAG"}
|
package/dist/lib/devMsg.js
CHANGED
package/dist/lib/devMsg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.js","names":[],"sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\"\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n * \t
|
|
1
|
+
{"version":3,"file":"devMsg.js","names":[],"sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\"\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n * \t;```ts\n * \tdevMsg(\"missing-param\")\n * \t// => \"https://prismic.dev/msg/next/v1.2.3/missing-param\"\n * \t```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in the Git repository's\n * `/messages` directory.\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string): string => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,UAAU,SAAyB;AAC/C,QAAO,iCAAiC,QAAQ,GAAG"}
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","StateEventType","SliceSimulatorWrapper"],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\"\nimport type {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n} from \"@prismicio/simulator/kit\"\nimport { useEffect, useState } from \"react\"\nimport type { ComponentType, FC } from \"react\"\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\"\n\nconst simulatorManager = new SimulatorManager()\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"]\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t * \t
|
|
1
|
+
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","StateEventType","SliceSimulatorWrapper"],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\"\nimport type {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n} from \"@prismicio/simulator/kit\"\nimport { useEffect, useState } from \"react\"\nimport type { ComponentType, FC } from \"react\"\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\"\n\nconst simulatorManager = new SimulatorManager()\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"]\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t * \t;```tsx\n\t * \timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\"\n\t * \timport { SliceZone } from \"@prismicio/react\"\n\t *\n\t * \timport { components } from \"../slices\"\n\t *\n\t * \t;<SliceSimulator\n\t * \t\tsliceZone={({ slices }) => <SliceZone slices={slices} components={components} />}\n\t * \t/>\n\t * \t```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>\n\tclassName?: string\n}\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine\n * and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tbackground,\n\tzIndex,\n\tclassName,\n\tsliceZone: SliceZoneComp,\n}) => {\n\tconst [slices, setSlices] = useState(() => getDefaultSlices())\n\tconst [message, setMessage] = useState(() => getDefaultMessage())\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices)\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t)\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message)\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t)\n\n\t\tsimulatorManager.init()\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\")\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\")\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={slices.length > 0}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<SliceZoneComp slices={slices} />\n\t\t</SliceSimulatorWrapper>\n\t)\n}\n"],"mappings":";;;;;;AAeA,MAAM,mBAAmB,IAAIA,yBAAAA,kBAAkB;;;;;AA8B/C,MAAa,kBAA2C,EACvD,YACA,QACA,WACA,WAAW,oBACN;CACL,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,iBAAA,GAAA,yBAAA,mBAA8C,CAAC;CAC9D,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,iBAAA,GAAA,yBAAA,oBAAgD,CAAC;AAEjE,EAAA,GAAA,MAAA,iBAAgB;AACf,mBAAiB,MAAM,GACtBC,yBAAAA,eAAe,SACd,YAAY;AACZ,aAAU,QAAQ;KAEnB,mBACA;AACD,mBAAiB,MAAM,GACtBA,yBAAAA,eAAe,UACd,aAAa;AACb,cAAW,SAAS;KAErB,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAIA,yBAAAA,eAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAIA,yBAAAA,eAAe,SAAS,oBAAoB;;IAEtE,EAAE,CAAC;AAEN,QACC,iBAAA,GAAA,kBAAA,KAACC,8BAAAA,uBAAD;EACU;EACT,WAAW,OAAO,SAAS;EACf;EACJ;EACG;YAEX,iBAAA,GAAA,kBAAA,KAAC,eAAD,EAAuB,QAAU,CAAA;EACV,CAAA"}
|
|
@@ -10,7 +10,7 @@ type SliceSimulatorProps$1 = SliceSimulatorProps & {
|
|
|
10
10
|
* React component to render simulated Slices.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
*
|
|
13
|
+
* ;```tsx
|
|
14
14
|
* import { SliceSimulator } from "@slicemachine/adapter-next/simulator"
|
|
15
15
|
* import { SliceZone } from "@prismicio/react"
|
|
16
16
|
*
|
|
@@ -10,7 +10,7 @@ type SliceSimulatorProps$1 = SliceSimulatorProps & {
|
|
|
10
10
|
* React component to render simulated Slices.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
*
|
|
13
|
+
* ;```tsx
|
|
14
14
|
* import { SliceSimulator } from "@slicemachine/adapter-next/simulator"
|
|
15
15
|
* import { SliceZone } from "@prismicio/react"
|
|
16
16
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\"\nimport type {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n} from \"@prismicio/simulator/kit\"\nimport { useEffect, useState } from \"react\"\nimport type { ComponentType, FC } from \"react\"\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\"\n\nconst simulatorManager = new SimulatorManager()\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"]\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t * \t
|
|
1
|
+
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\"\nimport type {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n} from \"@prismicio/simulator/kit\"\nimport { useEffect, useState } from \"react\"\nimport type { ComponentType, FC } from \"react\"\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\"\n\nconst simulatorManager = new SimulatorManager()\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"]\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t * \t;```tsx\n\t * \timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\"\n\t * \timport { SliceZone } from \"@prismicio/react\"\n\t *\n\t * \timport { components } from \"../slices\"\n\t *\n\t * \t;<SliceSimulator\n\t * \t\tsliceZone={({ slices }) => <SliceZone slices={slices} components={components} />}\n\t * \t/>\n\t * \t```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>\n\tclassName?: string\n}\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine\n * and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tbackground,\n\tzIndex,\n\tclassName,\n\tsliceZone: SliceZoneComp,\n}) => {\n\tconst [slices, setSlices] = useState(() => getDefaultSlices())\n\tconst [message, setMessage] = useState(() => getDefaultMessage())\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices)\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t)\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message)\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t)\n\n\t\tsimulatorManager.init()\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\")\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\")\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={slices.length > 0}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<SliceZoneComp slices={slices} />\n\t\t</SliceSimulatorWrapper>\n\t)\n}\n"],"mappings":";;;;;AAeA,MAAM,mBAAmB,IAAI,kBAAkB;;;;;AA8B/C,MAAa,kBAA2C,EACvD,YACA,QACA,WACA,WAAW,oBACN;CACL,MAAM,CAAC,QAAQ,aAAa,eAAe,kBAAkB,CAAC;CAC9D,MAAM,CAAC,SAAS,cAAc,eAAe,mBAAmB,CAAC;AAEjE,iBAAgB;AACf,mBAAiB,MAAM,GACtB,eAAe,SACd,YAAY;AACZ,aAAU,QAAQ;KAEnB,mBACA;AACD,mBAAiB,MAAM,GACtB,eAAe,UACd,aAAa;AACb,cAAW,SAAS;KAErB,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAI,eAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAI,eAAe,SAAS,oBAAoB;;IAEtE,EAAE,CAAC;AAEN,QACC,oBAAC,uBAAD;EACU;EACT,WAAW,OAAO,SAAS;EACf;EACJ;EACG;YAEX,oBAAC,eAAD,EAAuB,QAAU,CAAA;EACV,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.cjs","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t
|
|
1
|
+
{"version":3,"file":"exitPreview.cjs","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\tconfig.res.setHeader(\"Cache-Control\", \"no-store\")\n\n\tconfig.res.json({ success: true })\n\n\treturn\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,YAAY,QAAyC;AACpE,QAAO,IAAI,kBAAkB;AAG7B,QAAO,IAAI,UAAU,iBAAiB,WAAW;AAEjD,QAAO,IAAI,KAAK,EAAE,SAAS,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.js","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t
|
|
1
|
+
{"version":3,"file":"exitPreview.js","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\tconfig.res.setHeader(\"Cache-Control\", \"no-store\")\n\n\tconfig.res.json({ success: true })\n\n\treturn\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,YAAY,QAAyC;AACpE,QAAO,IAAI,kBAAkB;AAG7B,QAAO,IAAI,UAAU,iBAAiB,WAAW;AAEjD,QAAO,IAAI,KAAK,EAAE,SAAS,MAAM,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_getPrismicCacheTags = require("./getPrismicCacheTags.cjs");
|
|
3
|
+
let next_cache_js = require("next/cache.js");
|
|
4
|
+
//#region src/revalidatePrismicPages.ts
|
|
5
|
+
/**
|
|
6
|
+
* Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs
|
|
7
|
+
* typically comes from a Prismic webhook triggered when publishing content.
|
|
8
|
+
*
|
|
9
|
+
* @param ids - A list of Prismic page IDs to revalidate.
|
|
10
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
11
|
+
*/
|
|
12
|
+
function revalidatePrismicPages(ids) {
|
|
13
|
+
for (const id of ids) (0, next_cache_js.revalidateTag)(require_getPrismicCacheTags.buildPrismicCacheTag(id), { expire: 0 });
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.revalidatePrismicPages = revalidatePrismicPages;
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=revalidatePrismicPages.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidatePrismicPages.cjs","names":["buildPrismicCacheTag"],"sources":["../src/revalidatePrismicPages.ts"],"sourcesContent":["import { revalidateTag } from \"next/cache\"\n\nimport { buildPrismicCacheTag } from \"./getPrismicCacheTags\"\n\n/**\n * Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs\n * typically comes from a Prismic webhook triggered when publishing content.\n *\n * @param ids - A list of Prismic page IDs to revalidate.\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}\n */\nexport function revalidatePrismicPages(ids: string[]): void {\n\tfor (const id of ids) {\n\t\tconst tag = buildPrismicCacheTag(id)\n\t\trevalidateTag(tag, { expire: 0 })\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,uBAAuB,KAAqB;AAC3D,MAAK,MAAM,MAAM,IAEhB,EAAA,GAAA,cAAA,eADYA,4BAAAA,qBAAqB,GAAG,EACjB,EAAE,QAAQ,GAAG,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/revalidatePrismicPages.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs
|
|
4
|
+
* typically comes from a Prismic webhook triggered when publishing content.
|
|
5
|
+
*
|
|
6
|
+
* @param ids - A list of Prismic page IDs to revalidate.
|
|
7
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
8
|
+
*/
|
|
9
|
+
declare function revalidatePrismicPages(ids: string[]): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { revalidatePrismicPages };
|
|
12
|
+
//# sourceMappingURL=revalidatePrismicPages.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidatePrismicPages.d.cts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;AAWA;;;;;;iBAAgB,sBAAA,CAAuB,GAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/revalidatePrismicPages.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs
|
|
4
|
+
* typically comes from a Prismic webhook triggered when publishing content.
|
|
5
|
+
*
|
|
6
|
+
* @param ids - A list of Prismic page IDs to revalidate.
|
|
7
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
8
|
+
*/
|
|
9
|
+
declare function revalidatePrismicPages(ids: string[]): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { revalidatePrismicPages };
|
|
12
|
+
//# sourceMappingURL=revalidatePrismicPages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidatePrismicPages.d.ts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;AAWA;;;;;;iBAAgB,sBAAA,CAAuB,GAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { buildPrismicCacheTag } from "./getPrismicCacheTags.js";
|
|
2
|
+
import { revalidateTag } from "next/cache.js";
|
|
3
|
+
//#region src/revalidatePrismicPages.ts
|
|
4
|
+
/**
|
|
5
|
+
* Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs
|
|
6
|
+
* typically comes from a Prismic webhook triggered when publishing content.
|
|
7
|
+
*
|
|
8
|
+
* @param ids - A list of Prismic page IDs to revalidate.
|
|
9
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
10
|
+
*/
|
|
11
|
+
function revalidatePrismicPages(ids) {
|
|
12
|
+
for (const id of ids) revalidateTag(buildPrismicCacheTag(id), { expire: 0 });
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { revalidatePrismicPages };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=revalidatePrismicPages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidatePrismicPages.js","names":[],"sources":["../src/revalidatePrismicPages.ts"],"sourcesContent":["import { revalidateTag } from \"next/cache\"\n\nimport { buildPrismicCacheTag } from \"./getPrismicCacheTags\"\n\n/**\n * Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs\n * typically comes from a Prismic webhook triggered when publishing content.\n *\n * @param ids - A list of Prismic page IDs to revalidate.\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}\n */\nexport function revalidatePrismicPages(ids: string[]): void {\n\tfor (const id of ids) {\n\t\tconst tag = buildPrismicCacheTag(id)\n\t\trevalidateTag(tag, { expire: 0 })\n\t}\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,uBAAuB,KAAqB;AAC3D,MAAK,MAAM,MAAM,IAEhB,eADY,qBAAqB,GAAG,EACjB,EAAE,QAAQ,GAAG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/next",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4-pr.114.37ca25f",
|
|
4
4
|
"description": "Helpers to integrate Prismic into Next.js apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"next",
|
|
@@ -53,21 +53,21 @@
|
|
|
53
53
|
"types": "tsc --noEmit"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@prismicio/simulator": "^0.2.
|
|
56
|
+
"@prismicio/simulator": "^0.2.2",
|
|
57
57
|
"imgix-url-builder": "^0.0.6",
|
|
58
58
|
"lz-string": "^1.5.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@playwright/test": "^1.
|
|
62
|
-
"@prismicio/client": "^7.
|
|
63
|
-
"@types/node": "^25.5.
|
|
61
|
+
"@playwright/test": "^1.59.1",
|
|
62
|
+
"@prismicio/client": "^7.21.8",
|
|
63
|
+
"@types/node": "^25.5.2",
|
|
64
64
|
"@types/react": "^19.2.14",
|
|
65
|
-
"next": "16.2.
|
|
66
|
-
"oxfmt": "^0.
|
|
67
|
-
"oxlint": "^1.
|
|
68
|
-
"playwright": "^1.
|
|
69
|
-
"react": "^19.2.
|
|
70
|
-
"react-dom": "^19.2.
|
|
65
|
+
"next": "16.2.3",
|
|
66
|
+
"oxfmt": "^0.44.0",
|
|
67
|
+
"oxlint": "^1.59.0",
|
|
68
|
+
"playwright": "^1.59.1",
|
|
69
|
+
"react": "^19.2.5",
|
|
70
|
+
"react-dom": "^19.2.5",
|
|
71
71
|
"tsdown": "^0.21.7",
|
|
72
72
|
"typescript": "^6.0.2"
|
|
73
73
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PrismicDocument } from "@prismicio/client"
|
|
2
|
+
import { cacheTag } from "next/cache"
|
|
3
|
+
|
|
4
|
+
import { getPrismicCacheTags } from "./getPrismicCacheTags"
|
|
5
|
+
|
|
6
|
+
export function cacheTagPrismicPages(pages: PrismicDocument[]): void {
|
|
7
|
+
cacheTag(...getPrismicCacheTags(pages))
|
|
8
|
+
}
|
package/src/exitPreview.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PrismicDocument } from "@prismicio/client"
|
|
2
|
+
|
|
3
|
+
const CACHE_TAG_PREFIX = "prismic/"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generates cache tags for a set of Prismic pages. Tags for linked pages (e.g. a content
|
|
7
|
+
* relationship) are included to ensure all related content can be revalidated.
|
|
8
|
+
*
|
|
9
|
+
* @param pages - A set of Prismic pages used to tag the function.
|
|
10
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
11
|
+
*/
|
|
12
|
+
export function getPrismicCacheTags(pages: PrismicDocument[]): string[] {
|
|
13
|
+
const ids = [...new Set(getPrismicDocumentIDs(pages))]
|
|
14
|
+
return ids.map((id) => buildPrismicCacheTag(id))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function buildPrismicCacheTag(id: string): string {
|
|
18
|
+
return `${CACHE_TAG_PREFIX}${id}`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getPrismicDocumentIDs(input: unknown): string[] {
|
|
22
|
+
if (typeof input !== "object" || input == null) return []
|
|
23
|
+
|
|
24
|
+
if (Array.isArray(input)) return input.flatMap((item) => getPrismicDocumentIDs(item))
|
|
25
|
+
|
|
26
|
+
if ("id" in input && typeof input.id === "string") {
|
|
27
|
+
// Document
|
|
28
|
+
// Content relationship or link
|
|
29
|
+
if (
|
|
30
|
+
("href" in input &&
|
|
31
|
+
typeof input.href === "string" &&
|
|
32
|
+
input.href.includes("/api/v2/documents/search?")) ||
|
|
33
|
+
("link_type" in input && input.link_type === "Document")
|
|
34
|
+
) {
|
|
35
|
+
if ("data" in input && typeof input.data === "object" && input.data !== null) {
|
|
36
|
+
return [input.id, ...getPrismicDocumentIDs(input.data)]
|
|
37
|
+
} else {
|
|
38
|
+
return [input.id]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return Object.values(input).flatMap((input) => getPrismicDocumentIDs(input))
|
|
44
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -26,3 +26,9 @@ export type { CreateClientConfig } from "./types"
|
|
|
26
26
|
|
|
27
27
|
export { createLocaleRedirect } from "./createLocaleRedirect"
|
|
28
28
|
export type { CreateLocaleRedirectConfig } from "./createLocaleRedirect"
|
|
29
|
+
|
|
30
|
+
export { getPrismicCacheTags } from "./getPrismicCacheTags"
|
|
31
|
+
|
|
32
|
+
export { cacheTagPrismicPages } from "./cacheTagPrismicPages"
|
|
33
|
+
|
|
34
|
+
export { revalidatePrismicPages } from "./revalidatePrismicPages"
|
package/src/lib/devMsg.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type SliceSimulatorProps = BaseSliceSimulatorProps & {
|
|
|
24
24
|
* React component to render simulated Slices.
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
|
-
*
|
|
27
|
+
* ;```tsx
|
|
28
28
|
* import { SliceSimulator } from "@slicemachine/adapter-next/simulator"
|
|
29
29
|
* import { SliceZone } from "@prismicio/react"
|
|
30
30
|
*
|
package/src/pages/exitPreview.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { revalidateTag } from "next/cache"
|
|
2
|
+
|
|
3
|
+
import { buildPrismicCacheTag } from "./getPrismicCacheTags"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs
|
|
7
|
+
* typically comes from a Prismic webhook triggered when publishing content.
|
|
8
|
+
*
|
|
9
|
+
* @param ids - A list of Prismic page IDs to revalidate.
|
|
10
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
11
|
+
*/
|
|
12
|
+
export function revalidatePrismicPages(ids: string[]): void {
|
|
13
|
+
for (const id of ids) {
|
|
14
|
+
const tag = buildPrismicCacheTag(id)
|
|
15
|
+
revalidateTag(tag, { expire: 0 })
|
|
16
|
+
}
|
|
17
|
+
}
|