@prismicio/next 2.2.4-pr.114.5e44dbe → 2.3.0-pr.139.dd4bae7
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 +12 -0
- package/dist/cacheTagPrismicPages.cjs.map +1 -1
- package/dist/cacheTagPrismicPages.d.cts +12 -0
- package/dist/cacheTagPrismicPages.d.cts.map +1 -1
- package/dist/cacheTagPrismicPages.d.ts +12 -0
- package/dist/cacheTagPrismicPages.d.ts.map +1 -1
- package/dist/cacheTagPrismicPages.js +12 -0
- package/dist/cacheTagPrismicPages.js.map +1 -1
- package/dist/getPreviewRef.cjs +5 -6
- package/dist/getPreviewRef.cjs.map +1 -1
- package/dist/getPreviewRef.d.cts +5 -6
- package/dist/getPreviewRef.d.cts.map +1 -1
- package/dist/getPreviewRef.d.ts +5 -6
- package/dist/getPreviewRef.d.ts.map +1 -1
- package/dist/getPreviewRef.js +5 -6
- package/dist/getPreviewRef.js.map +1 -1
- package/dist/getPrismicCacheTags.cjs +2 -0
- package/dist/getPrismicCacheTags.cjs.map +1 -1
- package/dist/getPrismicCacheTags.d.cts +2 -0
- package/dist/getPrismicCacheTags.d.cts.map +1 -1
- package/dist/getPrismicCacheTags.d.ts +2 -0
- package/dist/getPrismicCacheTags.d.ts.map +1 -1
- package/dist/getPrismicCacheTags.js +2 -0
- package/dist/getPrismicCacheTags.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/revalidatePrismicPages.cjs +2 -0
- package/dist/revalidatePrismicPages.cjs.map +1 -1
- package/dist/revalidatePrismicPages.d.cts +2 -0
- package/dist/revalidatePrismicPages.d.cts.map +1 -1
- package/dist/revalidatePrismicPages.d.ts +2 -0
- package/dist/revalidatePrismicPages.d.ts.map +1 -1
- package/dist/revalidatePrismicPages.js +2 -0
- package/dist/revalidatePrismicPages.js.map +1 -1
- package/package.json +1 -1
- package/src/cacheTagPrismicPages.ts +12 -0
- package/src/getPreviewRef.ts +5 -6
- package/src/getPrismicCacheTags.ts +2 -0
- package/src/revalidatePrismicPages.ts +2 -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
|
} & {
|
|
@@ -2,6 +2,18 @@ require("./_virtual/_rolldown/runtime.cjs");
|
|
|
2
2
|
const require_getPrismicCacheTags = require("./getPrismicCacheTags.cjs");
|
|
3
3
|
let next_cache_js = require("next/cache.js");
|
|
4
4
|
//#region src/cacheTagPrismicPages.ts
|
|
5
|
+
/**
|
|
6
|
+
* Tags the current cache entry with cache tags for a set of Prismic pages so they can be
|
|
7
|
+
* revalidated when their content changes.
|
|
8
|
+
*
|
|
9
|
+
* Linked documents (via content relationships) are tagged as well, so the cache entry is
|
|
10
|
+
* revalidated when any of its nested documents change.
|
|
11
|
+
*
|
|
12
|
+
* @param pages - A set of Prismic pages used to tag the cache entry.
|
|
13
|
+
* @experimental
|
|
14
|
+
*
|
|
15
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
16
|
+
*/
|
|
5
17
|
function cacheTagPrismicPages(pages) {
|
|
6
18
|
(0, next_cache_js.cacheTag)(...require_getPrismicCacheTags.getPrismicCacheTags(pages));
|
|
7
19
|
}
|
|
@@ -1 +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":"
|
|
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\n/**\n * Tags the current cache entry with cache tags for a set of Prismic pages so they can be\n * revalidated when their content changes.\n *\n * Linked documents (via content relationships) are tagged as well, so the cache entry is\n * revalidated when any of its nested documents change.\n *\n * @param pages - A set of Prismic pages used to tag the cache entry.\n * @experimental\n *\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}\n */\nexport function cacheTagPrismicPages(pages: PrismicDocument[]): void {\n\tcacheTag(...getPrismicCacheTags(pages))\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,qBAAqB,OAAgC;AACpE,EAAA,GAAA,cAAA,UAAS,GAAGA,4BAAAA,oBAAoB,MAAM,CAAC"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { PrismicDocument } from "@prismicio/client";
|
|
2
2
|
|
|
3
3
|
//#region src/cacheTagPrismicPages.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Tags the current cache entry with cache tags for a set of Prismic pages so they can be
|
|
6
|
+
* revalidated when their content changes.
|
|
7
|
+
*
|
|
8
|
+
* Linked documents (via content relationships) are tagged as well, so the cache entry is
|
|
9
|
+
* revalidated when any of its nested documents change.
|
|
10
|
+
*
|
|
11
|
+
* @param pages - A set of Prismic pages used to tag the cache entry.
|
|
12
|
+
* @experimental
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
15
|
+
*/
|
|
4
16
|
declare function cacheTagPrismicPages(pages: PrismicDocument[]): void;
|
|
5
17
|
//#endregion
|
|
6
18
|
export { cacheTagPrismicPages };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheTagPrismicPages.d.cts","names":[],"sources":["../src/cacheTagPrismicPages.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cacheTagPrismicPages.d.cts","names":[],"sources":["../src/cacheTagPrismicPages.ts"],"mappings":";;;;;AAiBA;;;;;;;;;;iBAAgB,oBAAA,CAAqB,KAAA,EAAO,eAAA"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { PrismicDocument } from "@prismicio/client";
|
|
2
2
|
|
|
3
3
|
//#region src/cacheTagPrismicPages.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Tags the current cache entry with cache tags for a set of Prismic pages so they can be
|
|
6
|
+
* revalidated when their content changes.
|
|
7
|
+
*
|
|
8
|
+
* Linked documents (via content relationships) are tagged as well, so the cache entry is
|
|
9
|
+
* revalidated when any of its nested documents change.
|
|
10
|
+
*
|
|
11
|
+
* @param pages - A set of Prismic pages used to tag the cache entry.
|
|
12
|
+
* @experimental
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
15
|
+
*/
|
|
4
16
|
declare function cacheTagPrismicPages(pages: PrismicDocument[]): void;
|
|
5
17
|
//#endregion
|
|
6
18
|
export { cacheTagPrismicPages };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheTagPrismicPages.d.ts","names":[],"sources":["../src/cacheTagPrismicPages.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cacheTagPrismicPages.d.ts","names":[],"sources":["../src/cacheTagPrismicPages.ts"],"mappings":";;;;;AAiBA;;;;;;;;;;iBAAgB,oBAAA,CAAqB,KAAA,EAAO,eAAA"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { getPrismicCacheTags } from "./getPrismicCacheTags.js";
|
|
2
2
|
import { cacheTag } from "next/cache.js";
|
|
3
3
|
//#region src/cacheTagPrismicPages.ts
|
|
4
|
+
/**
|
|
5
|
+
* Tags the current cache entry with cache tags for a set of Prismic pages so they can be
|
|
6
|
+
* revalidated when their content changes.
|
|
7
|
+
*
|
|
8
|
+
* Linked documents (via content relationships) are tagged as well, so the cache entry is
|
|
9
|
+
* revalidated when any of its nested documents change.
|
|
10
|
+
*
|
|
11
|
+
* @param pages - A set of Prismic pages used to tag the cache entry.
|
|
12
|
+
* @experimental
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
15
|
+
*/
|
|
4
16
|
function cacheTagPrismicPages(pages) {
|
|
5
17
|
cacheTag(...getPrismicCacheTags(pages));
|
|
6
18
|
}
|
|
@@ -1 +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":"
|
|
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\n/**\n * Tags the current cache entry with cache tags for a set of Prismic pages so they can be\n * revalidated when their content changes.\n *\n * Linked documents (via content relationships) are tagged as well, so the cache entry is\n * revalidated when any of its nested documents change.\n *\n * @param pages - A set of Prismic pages used to tag the cache entry.\n * @experimental\n *\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}\n */\nexport function cacheTagPrismicPages(pages: PrismicDocument[]): void {\n\tcacheTag(...getPrismicCacheTags(pages))\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAgB,qBAAqB,OAAgC;AACpE,UAAS,GAAG,oBAAoB,MAAM,CAAC"}
|
package/dist/getPreviewRef.cjs
CHANGED
|
@@ -2,13 +2,11 @@ require("./_virtual/_rolldown/runtime.cjs");
|
|
|
2
2
|
let _prismicio_client = require("@prismicio/client");
|
|
3
3
|
//#region src/getPreviewRef.ts
|
|
4
4
|
/**
|
|
5
|
-
* Reads the Prismic preview ref for the current request when an active preview
|
|
6
|
-
* session exists.
|
|
5
|
+
* Reads the Prismic preview ref for the current request when an active preview session exists.
|
|
7
6
|
*
|
|
8
|
-
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* cache key:
|
|
7
|
+
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use
|
|
8
|
+
* it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as
|
|
9
|
+
* an argument so it becomes part of the cache key:
|
|
12
10
|
*
|
|
13
11
|
* @example
|
|
14
12
|
* ;```typescript
|
|
@@ -18,6 +16,7 @@ let _prismicio_client = require("@prismicio/client");
|
|
|
18
16
|
* ```
|
|
19
17
|
*
|
|
20
18
|
* @returns The active preview ref, or `undefined` if no preview session is active.
|
|
19
|
+
* @experimental
|
|
21
20
|
*/
|
|
22
21
|
async function getPreviewRef() {
|
|
23
22
|
const { cookies, draftMode } = await import("next/headers.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPreviewRef.cjs","names":["prismicCookie"],"sources":["../src/getPreviewRef.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\n/**\n * Reads the Prismic preview ref for the current request when an active preview
|
|
1
|
+
{"version":3,"file":"getPreviewRef.cjs","names":["prismicCookie"],"sources":["../src/getPreviewRef.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\n/**\n * Reads the Prismic preview ref for the current request when an active preview session exists.\n *\n * This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use\n * it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as\n * an argument so it becomes part of the cache key:\n *\n * @example\n * \t;```typescript\n * \timport { getPreviewRef } from \"@prismicio/next\"\n *\n * \tconst page = await fetchPage(uid, await getPreviewRef())\n * \t```\n *\n * @returns The active preview ref, or `undefined` if no preview session is active.\n * @experimental\n */\nexport async function getPreviewRef(): Promise<string | undefined> {\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 { cookies, draftMode } = await import(\"next/headers\")\n\n\tlet isDraftModeEnabled = false\n\ttry {\n\t\tisDraftModeEnabled = (await draftMode()).isEnabled\n\t} catch {\n\t\t// `draftMode()` may have been called in a place that\n\t\t// does not have access to its async storage. This\n\t\t// occurs in places like `generateStaticParams()`. We\n\t\t// can ignore this case.\n\t\treturn\n\t}\n\tif (!isDraftModeEnabled) {\n\t\treturn\n\t}\n\n\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value\n\tif (!cookie) {\n\t\treturn\n\t}\n\n\tconst isActiveCookie = cookie.includes(\"websitePreviewId=\")\n\tif (!isActiveCookie) {\n\t\treturn\n\t}\n\n\treturn cookie\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,eAAsB,gBAA6C;CAIlE,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,IAAI,qBAAqB;AACzB,KAAI;AACH,wBAAsB,MAAM,WAAW,EAAE;SAClC;AAKP;;AAED,KAAI,CAAC,mBACJ;CAGD,MAAM,UAAU,MAAM,SAAS,EAAE,IAAIA,kBAAAA,OAAc,QAAQ,EAAE;AAC7D,KAAI,CAAC,OACJ;AAID,KAAI,CADmB,OAAO,SAAS,oBAAoB,CAE1D;AAGD,QAAO"}
|
package/dist/getPreviewRef.d.cts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
//#region src/getPreviewRef.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Reads the Prismic preview ref for the current request when an active preview
|
|
4
|
-
* session exists.
|
|
3
|
+
* Reads the Prismic preview ref for the current request when an active preview session exists.
|
|
5
4
|
*
|
|
6
|
-
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* cache key:
|
|
5
|
+
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use
|
|
6
|
+
* it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as
|
|
7
|
+
* an argument so it becomes part of the cache key:
|
|
10
8
|
*
|
|
11
9
|
* @example
|
|
12
10
|
* ;```typescript
|
|
@@ -16,6 +14,7 @@
|
|
|
16
14
|
* ```
|
|
17
15
|
*
|
|
18
16
|
* @returns The active preview ref, or `undefined` if no preview session is active.
|
|
17
|
+
* @experimental
|
|
19
18
|
*/
|
|
20
19
|
declare function getPreviewRef(): Promise<string | undefined>;
|
|
21
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPreviewRef.d.cts","names":[],"sources":["../src/getPreviewRef.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"getPreviewRef.d.cts","names":[],"sources":["../src/getPreviewRef.ts"],"mappings":";;AAmBA;;;;;;;;;;;;;;;;iBAAsB,aAAA,CAAA,GAAiB,OAAA"}
|
package/dist/getPreviewRef.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
//#region src/getPreviewRef.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Reads the Prismic preview ref for the current request when an active preview
|
|
4
|
-
* session exists.
|
|
3
|
+
* Reads the Prismic preview ref for the current request when an active preview session exists.
|
|
5
4
|
*
|
|
6
|
-
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* cache key:
|
|
5
|
+
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use
|
|
6
|
+
* it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as
|
|
7
|
+
* an argument so it becomes part of the cache key:
|
|
10
8
|
*
|
|
11
9
|
* @example
|
|
12
10
|
* ;```typescript
|
|
@@ -16,6 +14,7 @@
|
|
|
16
14
|
* ```
|
|
17
15
|
*
|
|
18
16
|
* @returns The active preview ref, or `undefined` if no preview session is active.
|
|
17
|
+
* @experimental
|
|
19
18
|
*/
|
|
20
19
|
declare function getPreviewRef(): Promise<string | undefined>;
|
|
21
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPreviewRef.d.ts","names":[],"sources":["../src/getPreviewRef.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"getPreviewRef.d.ts","names":[],"sources":["../src/getPreviewRef.ts"],"mappings":";;AAmBA;;;;;;;;;;;;;;;;iBAAsB,aAAA,CAAA,GAAiB,OAAA"}
|
package/dist/getPreviewRef.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { cookie } from "@prismicio/client";
|
|
2
2
|
//#region src/getPreviewRef.ts
|
|
3
3
|
/**
|
|
4
|
-
* Reads the Prismic preview ref for the current request when an active preview
|
|
5
|
-
* session exists.
|
|
4
|
+
* Reads the Prismic preview ref for the current request when an active preview session exists.
|
|
6
5
|
*
|
|
7
|
-
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* cache key:
|
|
6
|
+
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use
|
|
7
|
+
* it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as
|
|
8
|
+
* an argument so it becomes part of the cache key:
|
|
11
9
|
*
|
|
12
10
|
* @example
|
|
13
11
|
* ;```typescript
|
|
@@ -17,6 +15,7 @@ import { cookie } from "@prismicio/client";
|
|
|
17
15
|
* ```
|
|
18
16
|
*
|
|
19
17
|
* @returns The active preview ref, or `undefined` if no preview session is active.
|
|
18
|
+
* @experimental
|
|
20
19
|
*/
|
|
21
20
|
async function getPreviewRef() {
|
|
22
21
|
const { cookies, draftMode } = await import("next/headers.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPreviewRef.js","names":["cookie","prismicCookie"],"sources":["../src/getPreviewRef.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\n/**\n * Reads the Prismic preview ref for the current request when an active preview
|
|
1
|
+
{"version":3,"file":"getPreviewRef.js","names":["cookie","prismicCookie"],"sources":["../src/getPreviewRef.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\n/**\n * Reads the Prismic preview ref for the current request when an active preview session exists.\n *\n * This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use\n * it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as\n * an argument so it becomes part of the cache key:\n *\n * @example\n * \t;```typescript\n * \timport { getPreviewRef } from \"@prismicio/next\"\n *\n * \tconst page = await fetchPage(uid, await getPreviewRef())\n * \t```\n *\n * @returns The active preview ref, or `undefined` if no preview session is active.\n * @experimental\n */\nexport async function getPreviewRef(): Promise<string | undefined> {\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 { cookies, draftMode } = await import(\"next/headers\")\n\n\tlet isDraftModeEnabled = false\n\ttry {\n\t\tisDraftModeEnabled = (await draftMode()).isEnabled\n\t} catch {\n\t\t// `draftMode()` may have been called in a place that\n\t\t// does not have access to its async storage. This\n\t\t// occurs in places like `generateStaticParams()`. We\n\t\t// can ignore this case.\n\t\treturn\n\t}\n\tif (!isDraftModeEnabled) {\n\t\treturn\n\t}\n\n\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value\n\tif (!cookie) {\n\t\treturn\n\t}\n\n\tconst isActiveCookie = cookie.includes(\"websitePreviewId=\")\n\tif (!isActiveCookie) {\n\t\treturn\n\t}\n\n\treturn cookie\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,eAAsB,gBAA6C;CAIlE,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,IAAI,qBAAqB;AACzB,KAAI;AACH,wBAAsB,MAAM,WAAW,EAAE;SAClC;AAKP;;AAED,KAAI,CAAC,mBACJ;CAGD,MAAMA,YAAU,MAAM,SAAS,EAAE,IAAIC,OAAc,QAAQ,EAAE;AAC7D,KAAI,CAACD,SACJ;AAID,KAAI,CADmBA,SAAO,SAAS,oBAAoB,CAE1D;AAGD,QAAOA"}
|
|
@@ -5,6 +5,8 @@ const CACHE_TAG_PREFIX = "prismic/";
|
|
|
5
5
|
* relationship) are included to ensure all related content can be revalidated.
|
|
6
6
|
*
|
|
7
7
|
* @param pages - A set of Prismic pages used to tag the function.
|
|
8
|
+
* @experimental
|
|
9
|
+
*
|
|
8
10
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
9
11
|
*/
|
|
10
12
|
function getPrismicCacheTags(pages) {
|
|
@@ -1 +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
|
|
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 * @experimental\n *\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;;;;;;;;;;AAWzB,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"}
|
|
@@ -6,6 +6,8 @@ import { PrismicDocument } from "@prismicio/client";
|
|
|
6
6
|
* relationship) are included to ensure all related content can be revalidated.
|
|
7
7
|
*
|
|
8
8
|
* @param pages - A set of Prismic pages used to tag the function.
|
|
9
|
+
* @experimental
|
|
10
|
+
*
|
|
9
11
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
10
12
|
*/
|
|
11
13
|
declare function getPrismicCacheTags(pages: PrismicDocument[]): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrismicCacheTags.d.cts","names":[],"sources":["../src/getPrismicCacheTags.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"getPrismicCacheTags.d.cts","names":[],"sources":["../src/getPrismicCacheTags.ts"],"mappings":";;;;;AAaA;;;;;;;iBAAgB,mBAAA,CAAoB,KAAA,EAAO,eAAA"}
|
|
@@ -6,6 +6,8 @@ import { PrismicDocument } from "@prismicio/client";
|
|
|
6
6
|
* relationship) are included to ensure all related content can be revalidated.
|
|
7
7
|
*
|
|
8
8
|
* @param pages - A set of Prismic pages used to tag the function.
|
|
9
|
+
* @experimental
|
|
10
|
+
*
|
|
9
11
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
10
12
|
*/
|
|
11
13
|
declare function getPrismicCacheTags(pages: PrismicDocument[]): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrismicCacheTags.d.ts","names":[],"sources":["../src/getPrismicCacheTags.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"getPrismicCacheTags.d.ts","names":[],"sources":["../src/getPrismicCacheTags.ts"],"mappings":";;;;;AAaA;;;;;;;iBAAgB,mBAAA,CAAoB,KAAA,EAAO,eAAA"}
|
|
@@ -5,6 +5,8 @@ const CACHE_TAG_PREFIX = "prismic/";
|
|
|
5
5
|
* relationship) are included to ensure all related content can be revalidated.
|
|
6
6
|
*
|
|
7
7
|
* @param pages - A set of Prismic pages used to tag the function.
|
|
8
|
+
* @experimental
|
|
9
|
+
*
|
|
8
10
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
9
11
|
*/
|
|
10
12
|
function getPrismicCacheTags(pages) {
|
|
@@ -1 +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
|
|
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 * @experimental\n *\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;;;;;;;;;;AAWzB,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/package.cjs
CHANGED
package/dist/package.js
CHANGED
|
@@ -7,6 +7,8 @@ let next_cache_js = require("next/cache.js");
|
|
|
7
7
|
* typically comes from a Prismic webhook triggered when publishing content.
|
|
8
8
|
*
|
|
9
9
|
* @param ids - A list of Prismic page IDs to revalidate.
|
|
10
|
+
* @experimental
|
|
11
|
+
*
|
|
10
12
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
11
13
|
*/
|
|
12
14
|
function revalidatePrismicPages(ids) {
|
|
@@ -1 +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":"
|
|
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 * @experimental\n *\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":";;;;;;;;;;;;;AAaA,SAAgB,uBAAuB,KAAqB;AAC3D,MAAK,MAAM,MAAM,IAEhB,EAAA,GAAA,cAAA,eADYA,4BAAAA,qBAAqB,GAAG,EACjB,EAAE,QAAQ,GAAG,CAAC"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* typically comes from a Prismic webhook triggered when publishing content.
|
|
5
5
|
*
|
|
6
6
|
* @param ids - A list of Prismic page IDs to revalidate.
|
|
7
|
+
* @experimental
|
|
8
|
+
*
|
|
7
9
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
8
10
|
*/
|
|
9
11
|
declare function revalidatePrismicPages(ids: string[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revalidatePrismicPages.d.cts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"revalidatePrismicPages.d.cts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;AAaA;;;;;;;;iBAAgB,sBAAA,CAAuB,GAAA"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* typically comes from a Prismic webhook triggered when publishing content.
|
|
5
5
|
*
|
|
6
6
|
* @param ids - A list of Prismic page IDs to revalidate.
|
|
7
|
+
* @experimental
|
|
8
|
+
*
|
|
7
9
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
8
10
|
*/
|
|
9
11
|
declare function revalidatePrismicPages(ids: string[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revalidatePrismicPages.d.ts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"revalidatePrismicPages.d.ts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;AAaA;;;;;;;;iBAAgB,sBAAA,CAAuB,GAAA"}
|
|
@@ -6,6 +6,8 @@ import { revalidateTag } from "next/cache.js";
|
|
|
6
6
|
* typically comes from a Prismic webhook triggered when publishing content.
|
|
7
7
|
*
|
|
8
8
|
* @param ids - A list of Prismic page IDs to revalidate.
|
|
9
|
+
* @experimental
|
|
10
|
+
*
|
|
9
11
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
10
12
|
*/
|
|
11
13
|
function revalidatePrismicPages(ids) {
|
|
@@ -1 +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":"
|
|
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 * @experimental\n *\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":";;;;;;;;;;;;AAaA,SAAgB,uBAAuB,KAAqB;AAC3D,MAAK,MAAM,MAAM,IAEhB,eADY,qBAAqB,GAAG,EACjB,EAAE,QAAQ,GAAG,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,6 +3,18 @@ import { cacheTag } from "next/cache"
|
|
|
3
3
|
|
|
4
4
|
import { getPrismicCacheTags } from "./getPrismicCacheTags"
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Tags the current cache entry with cache tags for a set of Prismic pages so they can be
|
|
8
|
+
* revalidated when their content changes.
|
|
9
|
+
*
|
|
10
|
+
* Linked documents (via content relationships) are tagged as well, so the cache entry is
|
|
11
|
+
* revalidated when any of its nested documents change.
|
|
12
|
+
*
|
|
13
|
+
* @param pages - A set of Prismic pages used to tag the cache entry.
|
|
14
|
+
* @experimental
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
17
|
+
*/
|
|
6
18
|
export function cacheTagPrismicPages(pages: PrismicDocument[]): void {
|
|
7
19
|
cacheTag(...getPrismicCacheTags(pages))
|
|
8
20
|
}
|
package/src/getPreviewRef.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { cookie as prismicCookie } from "@prismicio/client"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Reads the Prismic preview ref for the current request when an active preview
|
|
5
|
-
* session exists.
|
|
4
|
+
* Reads the Prismic preview ref for the current request when an active preview session exists.
|
|
6
5
|
*
|
|
7
|
-
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* cache key:
|
|
6
|
+
* This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use
|
|
7
|
+
* it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as
|
|
8
|
+
* an argument so it becomes part of the cache key:
|
|
11
9
|
*
|
|
12
10
|
* @example
|
|
13
11
|
* ;```typescript
|
|
@@ -17,6 +15,7 @@ import { cookie as prismicCookie } from "@prismicio/client"
|
|
|
17
15
|
* ```
|
|
18
16
|
*
|
|
19
17
|
* @returns The active preview ref, or `undefined` if no preview session is active.
|
|
18
|
+
* @experimental
|
|
20
19
|
*/
|
|
21
20
|
export async function getPreviewRef(): Promise<string | undefined> {
|
|
22
21
|
// Need this to avoid the following Next.js build-time error:
|
|
@@ -7,6 +7,8 @@ const CACHE_TAG_PREFIX = "prismic/"
|
|
|
7
7
|
* relationship) are included to ensure all related content can be revalidated.
|
|
8
8
|
*
|
|
9
9
|
* @param pages - A set of Prismic pages used to tag the function.
|
|
10
|
+
* @experimental
|
|
11
|
+
*
|
|
10
12
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/cacheTag}
|
|
11
13
|
*/
|
|
12
14
|
export function getPrismicCacheTags(pages: PrismicDocument[]): string[] {
|
|
@@ -7,6 +7,8 @@ import { buildPrismicCacheTag } from "./getPrismicCacheTags"
|
|
|
7
7
|
* typically comes from a Prismic webhook triggered when publishing content.
|
|
8
8
|
*
|
|
9
9
|
* @param ids - A list of Prismic page IDs to revalidate.
|
|
10
|
+
* @experimental
|
|
11
|
+
*
|
|
10
12
|
* @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
|
|
11
13
|
*/
|
|
12
14
|
export function revalidatePrismicPages(ids: string[]): void {
|