@prismicio/next 1.7.1 → 2.0.0-alpha.0
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/README.md +5 -3
- package/dist/PrismicNextImage.d.ts +7 -8
- package/dist/PrismicNextImage.js +8 -8
- package/dist/PrismicNextImage.js.map +1 -1
- package/dist/PrismicNextLink.d.ts +99 -100
- package/dist/PrismicNextLink.js +3 -5
- package/dist/PrismicNextLink.js.map +1 -1
- package/dist/PrismicPreview.d.ts +5 -13
- package/dist/PrismicPreview.js +6 -19
- package/dist/PrismicPreview.js.map +1 -1
- package/dist/PrismicPreviewClient.d.ts +5 -3
- package/dist/PrismicPreviewClient.js +58 -69
- package/dist/PrismicPreviewClient.js.map +1 -1
- package/dist/createLocaleRedirect.d.ts +8 -15
- package/dist/createLocaleRedirect.js +4 -28
- package/dist/createLocaleRedirect.js.map +1 -1
- package/dist/enableAutoPreviews.d.ts +7 -31
- package/dist/enableAutoPreviews.js +24 -35
- package/dist/enableAutoPreviews.js.map +1 -1
- package/dist/exitPreview.d.ts +4 -46
- package/dist/exitPreview.js +8 -15
- package/dist/exitPreview.js.map +1 -1
- package/dist/imgixLoader.js.map +1 -1
- package/dist/index.d.ts +15 -18
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/devMsg.d.ts +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/pages/PrismicPreview.d.ts +31 -0
- package/dist/pages/PrismicPreview.js +64 -0
- package/dist/pages/PrismicPreview.js.map +1 -0
- package/dist/pages/enableAutoPreviews.d.ts +31 -0
- package/dist/pages/enableAutoPreviews.js +19 -0
- package/dist/pages/enableAutoPreviews.js.map +1 -0
- package/dist/pages/exitPreview.d.ts +33 -0
- package/dist/pages/exitPreview.js +10 -0
- package/dist/pages/exitPreview.js.map +1 -0
- package/dist/pages/index.d.ts +18 -0
- package/dist/pages/redirectToPreviewURL.d.ts +43 -0
- package/dist/pages/redirectToPreviewURL.js +16 -0
- package/dist/pages/redirectToPreviewURL.js.map +1 -0
- package/dist/{setPreviewData.d.ts → pages/setPreviewData.d.ts} +3 -9
- package/dist/{setPreviewData.js → pages/setPreviewData.js} +2 -2
- package/dist/pages/setPreviewData.js.map +1 -0
- package/dist/pages/types.d.ts +30 -0
- package/dist/pages.js +21 -0
- package/dist/pages.js.map +1 -0
- package/dist/redirectToPreviewURL.d.ts +11 -41
- package/dist/redirectToPreviewURL.js +16 -22
- package/dist/redirectToPreviewURL.js.map +1 -1
- package/dist/types.d.ts +2 -51
- package/package.json +61 -54
- package/src/PrismicNextImage.tsx +19 -16
- package/src/PrismicNextLink.tsx +17 -13
- package/src/PrismicPreview.tsx +20 -50
- package/src/PrismicPreviewClient.tsx +111 -138
- package/src/createLocaleRedirect.ts +14 -56
- package/src/enableAutoPreviews.ts +38 -110
- package/src/exitPreview.ts +18 -81
- package/src/index.ts +15 -26
- package/src/lib/devMsg.ts +1 -1
- package/src/pages/PrismicPreview.tsx +145 -0
- package/src/pages/enableAutoPreviews.ts +62 -0
- package/src/pages/exitPreview.ts +45 -0
- package/src/pages/index.ts +27 -0
- package/src/pages/redirectToPreviewURL.ts +77 -0
- package/src/{setPreviewData.ts → pages/setPreviewData.ts} +5 -11
- package/src/pages/types.ts +36 -0
- package/src/redirectToPreviewURL.ts +44 -95
- package/src/types.ts +2 -56
- package/dist/PrismicNextImage.cjs +0 -64
- package/dist/PrismicNextImage.cjs.map +0 -1
- package/dist/PrismicNextLink.cjs +0 -40
- package/dist/PrismicNextLink.cjs.map +0 -1
- package/dist/PrismicPreview.cjs +0 -28
- package/dist/PrismicPreview.cjs.map +0 -1
- package/dist/PrismicPreviewClient.cjs +0 -81
- package/dist/PrismicPreviewClient.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/cookie.cjs +0 -5
- package/dist/_node_modules/@prismicio/client/dist/cookie.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/cookie.js +0 -5
- package/dist/_node_modules/@prismicio/client/dist/cookie.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs +0 -16
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js +0 -16
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs +0 -13
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js +0 -13
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs +0 -47
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js +0 -47
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs +0 -28
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js +0 -28
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs +0 -27
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js +0 -27
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs +0 -14
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js +0 -14
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs +0 -7
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js +0 -7
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs +0 -9
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js +0 -9
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs +0 -10
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.js +0 -10
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.js.map +0 -1
- package/dist/createLocaleRedirect.cjs +0 -32
- package/dist/createLocaleRedirect.cjs.map +0 -1
- package/dist/enableAutoPreviews.cjs +0 -40
- package/dist/enableAutoPreviews.cjs.map +0 -1
- package/dist/exitPreview.cjs +0 -20
- package/dist/exitPreview.cjs.map +0 -1
- package/dist/imgixLoader.cjs +0 -17
- package/dist/imgixLoader.cjs.map +0 -1
- package/dist/index.cjs +0 -21
- package/dist/index.cjs.map +0 -1
- package/dist/lib/devMsg.cjs +0 -8
- package/dist/lib/devMsg.cjs.map +0 -1
- package/dist/lib/getPreviewCookieRepositoryName.cjs +0 -7
- package/dist/lib/getPreviewCookieRepositoryName.cjs.map +0 -1
- package/dist/lib/getPreviewCookieRepositoryName.d.ts +0 -9
- package/dist/lib/getPreviewCookieRepositoryName.js +0 -7
- package/dist/lib/getPreviewCookieRepositoryName.js.map +0 -1
- package/dist/lib/getPrismicPreviewCookie.cjs +0 -21
- package/dist/lib/getPrismicPreviewCookie.cjs.map +0 -1
- package/dist/lib/getPrismicPreviewCookie.d.ts +0 -9
- package/dist/lib/getPrismicPreviewCookie.js +0 -21
- package/dist/lib/getPrismicPreviewCookie.js.map +0 -1
- package/dist/package.json.cjs +0 -5
- package/dist/package.json.cjs.map +0 -1
- package/dist/redirectToPreviewURL.cjs +0 -30
- package/dist/redirectToPreviewURL.cjs.map +0 -1
- package/dist/setPreviewData.cjs +0 -11
- package/dist/setPreviewData.cjs.map +0 -1
- package/dist/setPreviewData.js.map +0 -1
- package/src/lib/getPreviewCookieRepositoryName.ts +0 -14
- package/src/lib/getPrismicPreviewCookie.ts +0 -33
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentToLinkField.js","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/documentToLinkField.js"],"sourcesContent":["import { LinkType } from \"../types/value/link.js\";\nconst documentToLinkField = (prismicDocument) => {\n var _a;\n return {\n link_type: LinkType.Document,\n id: prismicDocument.id,\n uid: prismicDocument.uid || void 0,\n type: prismicDocument.type,\n tags: prismicDocument.tags,\n lang: prismicDocument.lang,\n url: prismicDocument.url == null ? void 0 : prismicDocument.url,\n slug: (_a = prismicDocument.slugs) == null ? void 0 : _a[0],\n // Slug field is not available with GraphQL\n // The REST API does not include a `data` property if the data\n // object is empty.\n //\n // A presence check for `prismicDocument.data` is done to\n // support partial documents. While `documentToLinkField` is\n // not typed to accept partial documents, passing a partial\n // document can happen in untyped projects.\n ...prismicDocument.data && Object.keys(prismicDocument.data).length > 0 ? { data: prismicDocument.data } : {}\n };\n};\nexport {\n documentToLinkField\n};\n//# sourceMappingURL=documentToLinkField.js.map\n"],"names":[],"mappings":";AACK,MAAC,sBAAsB,CAAC,oBAAoB;AAC/C,MAAI;AACJ,SAAO;AAAA,IACL,WAAW,SAAS;AAAA,IACpB,IAAI,gBAAgB;AAAA,IACpB,KAAK,gBAAgB,OAAO;AAAA,IAC5B,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,KAAK,gBAAgB,OAAO,OAAO,SAAS,gBAAgB;AAAA,IAC5D,OAAO,KAAK,gBAAgB,UAAU,OAAO,SAAS,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAS1D,GAAG,gBAAgB,QAAQ,OAAO,KAAK,gBAAgB,IAAI,EAAE,SAAS,IAAI,EAAE,MAAM,gBAAgB,KAAM,IAAG,CAAE;AAAA,EACjH;AACA;","x_google_ignoreList":[0]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const isNonNullish = (input) => {
|
|
4
|
-
return input != null;
|
|
5
|
-
};
|
|
6
|
-
const imageThumbnail = (thumbnail) => {
|
|
7
|
-
return isNonNullish(thumbnail) && !!thumbnail.url;
|
|
8
|
-
};
|
|
9
|
-
const link = (field) => {
|
|
10
|
-
return isNonNullish(field) && ("id" in field || "url" in field);
|
|
11
|
-
};
|
|
12
|
-
exports.imageThumbnail = imageThumbnail;
|
|
13
|
-
exports.link = link;
|
|
14
|
-
//# sourceMappingURL=isFilled.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isFilled.cjs","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/isFilled.js"],"sourcesContent":["const isNonNullish = (input) => {\n return input != null;\n};\nconst isNonEmptyArray = (input) => {\n return !!input.length;\n};\nconst richText = (field) => {\n if (!isNonNullish(field)) {\n return false;\n } else if (field.length === 1 && \"text\" in field[0]) {\n return !!field[0].text;\n } else {\n return !!field.length;\n }\n};\nconst title = richText;\nconst imageThumbnail = (thumbnail) => {\n return isNonNullish(thumbnail) && !!thumbnail.url;\n};\nconst image = imageThumbnail;\nconst link = (field) => {\n return isNonNullish(field) && (\"id\" in field || \"url\" in field);\n};\nconst linkToMedia = link;\nconst contentRelationship = link;\nconst date = isNonNullish;\nconst timestamp = isNonNullish;\nconst color = isNonNullish;\nconst number = isNonNullish;\nconst keyText = (field) => {\n return isNonNullish(keyText) && !!field;\n};\nconst select = isNonNullish;\nconst embed = (field) => {\n return isNonNullish(field) && !!field.embed_url;\n};\nconst geoPoint = (field) => {\n return isNonNullish(field) && \"longitude\" in field;\n};\nconst integrationField = isNonNullish;\nconst integrationFields = integrationField;\nconst group = (group2) => {\n return isNonNullish(group2) && isNonEmptyArray(group2);\n};\nconst sliceZone = (slices) => {\n return isNonNullish(slices) && isNonEmptyArray(slices);\n};\nexport {\n color,\n contentRelationship,\n date,\n embed,\n geoPoint,\n group,\n image,\n imageThumbnail,\n integrationField,\n integrationFields,\n keyText,\n link,\n linkToMedia,\n number,\n richText,\n select,\n sliceZone,\n timestamp,\n title\n};\n//# sourceMappingURL=isFilled.js.map\n"],"names":[],"mappings":";;AAAA,MAAM,eAAe,CAAC,UAAU;AAC9B,SAAO,SAAS;AAClB;AAcK,MAAC,iBAAiB,CAAC,cAAc;AACpC,SAAO,aAAa,SAAS,KAAK,CAAC,CAAC,UAAU;AAChD;AAEK,MAAC,OAAO,CAAC,UAAU;AACtB,SAAO,aAAa,KAAK,MAAM,QAAQ,SAAS,SAAS;AAC3D;;;","x_google_ignoreList":[0]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const isNonNullish = (input) => {
|
|
2
|
-
return input != null;
|
|
3
|
-
};
|
|
4
|
-
const imageThumbnail = (thumbnail) => {
|
|
5
|
-
return isNonNullish(thumbnail) && !!thumbnail.url;
|
|
6
|
-
};
|
|
7
|
-
const link = (field) => {
|
|
8
|
-
return isNonNullish(field) && ("id" in field || "url" in field);
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
imageThumbnail,
|
|
12
|
-
link
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=isFilled.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isFilled.js","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/isFilled.js"],"sourcesContent":["const isNonNullish = (input) => {\n return input != null;\n};\nconst isNonEmptyArray = (input) => {\n return !!input.length;\n};\nconst richText = (field) => {\n if (!isNonNullish(field)) {\n return false;\n } else if (field.length === 1 && \"text\" in field[0]) {\n return !!field[0].text;\n } else {\n return !!field.length;\n }\n};\nconst title = richText;\nconst imageThumbnail = (thumbnail) => {\n return isNonNullish(thumbnail) && !!thumbnail.url;\n};\nconst image = imageThumbnail;\nconst link = (field) => {\n return isNonNullish(field) && (\"id\" in field || \"url\" in field);\n};\nconst linkToMedia = link;\nconst contentRelationship = link;\nconst date = isNonNullish;\nconst timestamp = isNonNullish;\nconst color = isNonNullish;\nconst number = isNonNullish;\nconst keyText = (field) => {\n return isNonNullish(keyText) && !!field;\n};\nconst select = isNonNullish;\nconst embed = (field) => {\n return isNonNullish(field) && !!field.embed_url;\n};\nconst geoPoint = (field) => {\n return isNonNullish(field) && \"longitude\" in field;\n};\nconst integrationField = isNonNullish;\nconst integrationFields = integrationField;\nconst group = (group2) => {\n return isNonNullish(group2) && isNonEmptyArray(group2);\n};\nconst sliceZone = (slices) => {\n return isNonNullish(slices) && isNonEmptyArray(slices);\n};\nexport {\n color,\n contentRelationship,\n date,\n embed,\n geoPoint,\n group,\n image,\n imageThumbnail,\n integrationField,\n integrationFields,\n keyText,\n link,\n linkToMedia,\n number,\n richText,\n select,\n sliceZone,\n timestamp,\n title\n};\n//# sourceMappingURL=isFilled.js.map\n"],"names":[],"mappings":"AAAA,MAAM,eAAe,CAAC,UAAU;AAC9B,SAAO,SAAS;AAClB;AAcK,MAAC,iBAAiB,CAAC,cAAc;AACpC,SAAO,aAAa,SAAS,KAAK,CAAC,CAAC,UAAU;AAChD;AAEK,MAAC,OAAO,CAAC,UAAU;AACtB,SAAO,aAAa,KAAK,MAAM,QAAQ,SAAS,SAAS;AAC3D;","x_google_ignoreList":[0]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const isRepositoryName = (input) => {
|
|
4
|
-
return /^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/.test(input);
|
|
5
|
-
};
|
|
6
|
-
exports.isRepositoryName = isRepositoryName;
|
|
7
|
-
//# sourceMappingURL=isRepositoryName.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isRepositoryName.cjs","sources":["../../../../../node_modules/@prismicio/client/dist/isRepositoryName.js"],"sourcesContent":["const isRepositoryName = (input) => {\n return /^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/.test(input);\n};\nexport {\n isRepositoryName\n};\n//# sourceMappingURL=isRepositoryName.js.map\n"],"names":[],"mappings":";;AAAK,MAAC,mBAAmB,CAAC,UAAU;AAClC,SAAO,2CAA2C,KAAK,KAAK;AAC9D;;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isRepositoryName.js","sources":["../../../../../node_modules/@prismicio/client/dist/isRepositoryName.js"],"sourcesContent":["const isRepositoryName = (input) => {\n return /^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/.test(input);\n};\nexport {\n isRepositoryName\n};\n//# sourceMappingURL=isRepositoryName.js.map\n"],"names":[],"mappings":"AAAK,MAAC,mBAAmB,CAAC,UAAU;AAClC,SAAO,2CAA2C,KAAK,KAAK;AAC9D;","x_google_ignoreList":[0]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const isInternalURL = (url) => {
|
|
4
|
-
const isInternal = /^(\/(?!\/)|#)/.test(url);
|
|
5
|
-
const isSpecialLink = !isInternal && !/^https?:\/\//.test(url);
|
|
6
|
-
return isInternal && !isSpecialLink;
|
|
7
|
-
};
|
|
8
|
-
exports.isInternalURL = isInternalURL;
|
|
9
|
-
//# sourceMappingURL=isInternalURL.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isInternalURL.cjs","sources":["../../../../../../node_modules/@prismicio/client/dist/lib/isInternalURL.js"],"sourcesContent":["const isInternalURL = (url) => {\n const isInternal = /^(\\/(?!\\/)|#)/.test(url);\n const isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url);\n return isInternal && !isSpecialLink;\n};\nexport {\n isInternalURL\n};\n//# sourceMappingURL=isInternalURL.js.map\n"],"names":[],"mappings":";;AAAK,MAAC,gBAAgB,CAAC,QAAQ;AAC7B,QAAM,aAAa,gBAAgB,KAAK,GAAG;AAC3C,QAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,GAAG;AAC7D,SAAO,cAAc,CAAC;AACxB;;","x_google_ignoreList":[0]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const isInternalURL = (url) => {
|
|
2
|
-
const isInternal = /^(\/(?!\/)|#)/.test(url);
|
|
3
|
-
const isSpecialLink = !isInternal && !/^https?:\/\//.test(url);
|
|
4
|
-
return isInternal && !isSpecialLink;
|
|
5
|
-
};
|
|
6
|
-
export {
|
|
7
|
-
isInternalURL
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=isInternalURL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isInternalURL.js","sources":["../../../../../../node_modules/@prismicio/client/dist/lib/isInternalURL.js"],"sourcesContent":["const isInternalURL = (url) => {\n const isInternal = /^(\\/(?!\\/)|#)/.test(url);\n const isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url);\n return isInternal && !isSpecialLink;\n};\nexport {\n isInternalURL\n};\n//# sourceMappingURL=isInternalURL.js.map\n"],"names":[],"mappings":"AAAK,MAAC,gBAAgB,CAAC,QAAQ;AAC7B,QAAM,aAAa,gBAAgB,KAAK,GAAG;AAC3C,QAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,GAAG;AAC7D,SAAO,cAAc,CAAC;AACxB;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../../../../../../node_modules/@prismicio/client/dist/types/value/link.js"],"sourcesContent":["const LinkType = {\n Any: \"Any\",\n Document: \"Document\",\n Media: \"Media\",\n Web: \"Web\"\n};\nexport {\n LinkType\n};\n//# sourceMappingURL=link.js.map\n"],"names":[],"mappings":";;AAAK,MAAC,WAAW;AAAA,EACf,KAAK;AAAA,EACL,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;AACP;;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../../../../../../node_modules/@prismicio/client/dist/types/value/link.js"],"sourcesContent":["const LinkType = {\n Any: \"Any\",\n Document: \"Document\",\n Media: \"Media\",\n Web: \"Web\"\n};\nexport {\n LinkType\n};\n//# sourceMappingURL=link.js.map\n"],"names":[],"mappings":"AAAK,MAAC,WAAW;AAAA,EACf,KAAK;AAAA,EACL,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;AACP;","x_google_ignoreList":[0]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const Negotiator = require("negotiator");
|
|
4
|
-
const intlLocalematcher = require("@formatjs/intl-localematcher");
|
|
5
|
-
const createLocaleRedirect = async (config) => {
|
|
6
|
-
const repository = await config.client.getRepository();
|
|
7
|
-
const locales = repository.languages.map((language) => {
|
|
8
|
-
var _a;
|
|
9
|
-
return ((_a = config.localeOverrides) == null ? void 0 : _a[language.id]) ?? language.id;
|
|
10
|
-
});
|
|
11
|
-
const defaultLocale = locales[0];
|
|
12
|
-
const { pathname } = config.request.nextUrl;
|
|
13
|
-
const pathnameHasLocale = locales.some((locale2) => pathname.startsWith(`/${locale2}/`) || pathname === `/${locale2}`);
|
|
14
|
-
if (pathnameHasLocale) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
let locale = defaultLocale;
|
|
18
|
-
const headers = {
|
|
19
|
-
"accept-language": config.request.headers.get("accept-language") ?? void 0
|
|
20
|
-
};
|
|
21
|
-
if (headers["accept-language"]) {
|
|
22
|
-
const languages = new Negotiator({ headers }).languages();
|
|
23
|
-
locale = intlLocalematcher.match(languages, locales, defaultLocale);
|
|
24
|
-
}
|
|
25
|
-
if (locale === defaultLocale && config.omitDefaultLocale) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
config.request.nextUrl.pathname = `/${locale}${pathname}`;
|
|
29
|
-
return Response.redirect(config.request.nextUrl);
|
|
30
|
-
};
|
|
31
|
-
exports.createLocaleRedirect = createLocaleRedirect;
|
|
32
|
-
//# sourceMappingURL=createLocaleRedirect.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createLocaleRedirect.cjs","sources":["../../src/createLocaleRedirect.ts"],"sourcesContent":["import Negotiator from \"negotiator\";\nimport { match } from \"@formatjs/intl-localematcher\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { NextRequestLike } from \"./types\";\n\nexport type CreateLocaleRedirectConfig = {\n\trequest: NextRequestLike;\n\tclient: Pick<prismic.Client, \"getRepository\">;\n\tlocaleOverrides?: Record<string, string>;\n\tomitDefaultLocale?: boolean;\n};\n\n/**\n * Creates a `Response` that redirects a request to the requester's preferred\n * locale. This function returns `undefined` if the request already contains a\n * locale.\n *\n * @returns A `Response` if the request should be redirected, `undefined`\n * otherwise.\n */\nexport const createLocaleRedirect = async (\n\tconfig: CreateLocaleRedirectConfig,\n): Promise<Response | undefined> => {\n\tconst repository = await config.client.getRepository();\n\n\tconst locales = repository.languages.map((language) => {\n\t\treturn config.localeOverrides?.[language.id] ?? language.id;\n\t});\n\tconst defaultLocale = locales[0];\n\n\tconst { pathname } = config.request.nextUrl;\n\tconst pathnameHasLocale = locales.some(\n\t\t(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`,\n\t);\n\n\tif (pathnameHasLocale) {\n\t\treturn;\n\t}\n\n\tlet locale = defaultLocale;\n\n\tconst headers = {\n\t\t\"accept-language\":\n\t\t\tconfig.request.headers.get(\"accept-language\") ?? undefined,\n\t};\n\n\tif (headers[\"accept-language\"]) {\n\t\tconst languages = new Negotiator({ headers }).languages();\n\t\tlocale = match(languages, locales, defaultLocale);\n\t}\n\n\tif (locale === defaultLocale && config.omitDefaultLocale) {\n\t\treturn;\n\t}\n\n\tconfig.request.nextUrl.pathname = `/${locale}${pathname}`;\n\n\treturn Response.redirect(config.request.nextUrl as URL);\n};\n"],"names":["locale","match"],"mappings":";;;;AAqBa,MAAA,uBAAuB,OACnC,WACkC;AAClC,QAAM,aAAa,MAAM,OAAO,OAAO,cAAa;AAEpD,QAAM,UAAU,WAAW,UAAU,IAAI,CAAC,aAAY;;AACrD,aAAO,YAAO,oBAAP,mBAAyB,SAAS,QAAO,SAAS;AAAA,EAAA,CACzD;AACK,QAAA,gBAAgB,QAAQ,CAAC;AAE/B,QAAM,EAAE,SAAa,IAAA,OAAO,QAAQ;AACpC,QAAM,oBAAoB,QAAQ,KACjC,CAACA,YAAW,SAAS,WAAW,IAAIA,OAAM,GAAG,KAAK,aAAa,IAAIA,OAAM,EAAE;AAG5E,MAAI,mBAAmB;AACtB;AAAA,EACA;AAED,MAAI,SAAS;AAEb,QAAM,UAAU;AAAA,IACf,mBACC,OAAO,QAAQ,QAAQ,IAAI,iBAAiB,KAAK;AAAA,EAAA;AAG/C,MAAA,QAAQ,iBAAiB,GAAG;AAC/B,UAAM,YAAY,IAAI,WAAW,EAAE,QAAS,CAAA,EAAE;AACrC,aAAAC,kBAAAA,MAAM,WAAW,SAAS,aAAa;AAAA,EAChD;AAEG,MAAA,WAAW,iBAAiB,OAAO,mBAAmB;AACzD;AAAA,EACA;AAED,SAAO,QAAQ,QAAQ,WAAW,IAAI,MAAM,GAAG,QAAQ;AAEvD,SAAO,SAAS,SAAS,OAAO,QAAQ,OAAc;AACvD;;"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const headers = require("next/headers");
|
|
4
|
-
const cookie = require('./_node_modules/@prismicio/client/dist/cookie.cjs');
|
|
5
|
-
const isPrismicPreviewData = (input) => {
|
|
6
|
-
return typeof input === "object" && input !== null && "ref" in input;
|
|
7
|
-
};
|
|
8
|
-
const enableAutoPreviews = (config) => {
|
|
9
|
-
if ("previewData" in config && config.previewData) {
|
|
10
|
-
if (isPrismicPreviewData(config.previewData)) {
|
|
11
|
-
config.client.queryContentFromRef(config.previewData.ref);
|
|
12
|
-
}
|
|
13
|
-
} else if ("req" in config && config.req) {
|
|
14
|
-
config.client.enableAutoPreviewsFromReq(config.req);
|
|
15
|
-
} else {
|
|
16
|
-
config.client.queryContentFromRef(async () => {
|
|
17
|
-
var _a;
|
|
18
|
-
let isDraftModeEnabled = false;
|
|
19
|
-
try {
|
|
20
|
-
isDraftModeEnabled = (await headers.draftMode()).isEnabled;
|
|
21
|
-
} catch {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (!isDraftModeEnabled) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let cookie$1;
|
|
28
|
-
try {
|
|
29
|
-
cookie$1 = (_a = (await headers.cookies()).get(cookie.preview)) == null ? void 0 : _a.value;
|
|
30
|
-
} catch {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (cookie$1 && /\.prismic\.io/.test(cookie$1)) {
|
|
34
|
-
return cookie$1;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.enableAutoPreviews = enableAutoPreviews;
|
|
40
|
-
//# sourceMappingURL=enableAutoPreviews.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.cjs","sources":["../../src/enableAutoPreviews.ts"],"sourcesContent":["import { draftMode, cookies } from \"next/headers\";\nimport { PreviewData } from \"next\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { NextApiRequestLike, PrismicPreviewData } from \"./types\";\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig<\n\tTPreviewData extends PreviewData = PreviewData,\n> = {\n\t/**\n\t * Prismic client with which automatic previews will be enabled.\n\t */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<\n\t\tprismic.Client,\n\t\t\"queryContentFromRef\" | \"enableAutoPreviewsFromReq\"\n\t>;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `previewData` object provided in the `getStaticProps()` or\n\t * `getServerSideProps()` context object.\n\t */\n\tpreviewData?: TPreviewData;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\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\nconst isPrismicPreviewData = (input: unknown): input is PrismicPreviewData => {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input;\n};\n\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session. It either takes in a Next.js `getStaticProps` context object\n * or a Next.js API endpoint request object.\n *\n * @param config - Configuration for the function.\n */\nexport const enableAutoPreviews = <TPreviewData extends PreviewData>(\n\tconfig: EnableAutoPreviewsConfig<TPreviewData>,\n): void => {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode (`pages`\n\t\t// directory).\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref);\n\t\t}\n\t} else if (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route (`pages` directory).\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req);\n\t} else {\n\t\t// Assume we are in App Router (`app` directory) OR\n\t\t// `getStaticProps()`/`getServerSideProps()` with an inactive\n\t\t// Preview Mode (`pages` directory).\n\n\t\t// We use a function value so the cookie is checked on every\n\t\t// request. We don't have a static value to read from.\n\t\tconfig.client.queryContentFromRef(async () => {\n\t\t\tlet isDraftModeEnabled = false;\n\t\t\ttry {\n\t\t\t\tisDraftModeEnabled = (await draftMode()).isEnabled;\n\t\t\t} catch {\n\t\t\t\t// This catch block may be reached if\n\t\t\t\t// `draftMode()` is called in a place that does\n\t\t\t\t// not have access to its async storage. We can\n\t\t\t\t// ignore this case.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!isDraftModeEnabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet cookie: string | undefined;\n\t\t\ttry {\n\t\t\t\tcookie = (await cookies()).get(prismic.cookie.preview)?.value;\n\t\t\t} catch {\n\t\t\t\t// We are probably in `getStaticProps()` or\n\t\t\t\t// `getServerSideProps()` with inactive Preview\n\t\t\t\t// Mode where `cookies()` does not work. We\n\t\t\t\t// don't need to do any preview handling.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We only return the cookie if a Prismic Preview session is active.\n\t\t\t//\n\t\t\t// An inactive cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\"\n\t\t\t// \t}\n\t\t\t//\n\t\t\t// An active cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\",\n\t\t\t// \t\t\"example-prismic-repo.prismic.io\": {\n\t\t\t// \t\t\tpreview: \"https://example-prismic-repo.prismic.io/previews/abc:123?websitePreviewId=xyz\"\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\tif (cookie && /\\.prismic\\.io/.test(cookie)) {\n\t\t\t\treturn cookie;\n\t\t\t}\n\t\t});\n\t}\n};\n"],"names":["draftMode","cookie","cookies","prismic.cookie.preview"],"mappings":";;;;AA2CA,MAAM,uBAAuB,CAAC,UAA+C;AAC5E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE;AASa,MAAA,qBAAqB,CACjC,WACS;AACL,MAAA,iBAAiB,UAAU,OAAO,aAAa;AAK9C,QAAA,qBAAqB,OAAO,WAAW,GAAG;AAC7C,aAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;AAAA,IACxD;AAAA,EACS,WAAA,SAAS,UAAU,OAAO,KAAK;AAGlC,WAAA,OAAO,0BAA0B,OAAO,GAAG;AAAA,EAAA,OAC5C;AAOC,WAAA,OAAO,oBAAoB,YAAW;;AAC5C,UAAI,qBAAqB;AACrB,UAAA;AACmB,8BAAA,MAAMA,kBAAa,GAAA;AAAA,MAAA,QAClC;AAMP;AAAA,MACA;AAED,UAAI,CAAC,oBAAoB;AACxB;AAAA,MACA;AAEG,UAAAC;AACA,UAAA;AACHA,oBAAU,YAAMC,QAAO,QAAA,GAAI,IAAIC,OAAAA,OAAsB,MAA3C,mBAA8C;AAAA,MAAA,QACjD;AAMP;AAAA,MACA;AAgBD,UAAIF,YAAU,gBAAgB,KAAKA,QAAM,GAAG;AACpC,eAAAA;AAAAA,MACP;AAAA,IAAA,CACD;AAAA,EACD;AACF;;"}
|
package/dist/exitPreview.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const headers = require("next/headers");
|
|
4
|
-
async function exitPreview(config) {
|
|
5
|
-
if (config == null ? void 0 : config.res) {
|
|
6
|
-
config.res.clearPreviewData();
|
|
7
|
-
config.res.setHeader("Cache-Control", "no-store");
|
|
8
|
-
config.res.json({ success: true });
|
|
9
|
-
return;
|
|
10
|
-
} else {
|
|
11
|
-
(await headers.draftMode()).disable();
|
|
12
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
13
|
-
headers: {
|
|
14
|
-
"Cache-Control": "no-store"
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.exitPreview = exitPreview;
|
|
20
|
-
//# sourceMappingURL=exitPreview.cjs.map
|
package/dist/exitPreview.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.cjs","sources":["../../src/exitPreview.ts"],"sourcesContent":["import { draftMode } from \"next/headers\";\n\nimport { NextApiRequestLike, NextApiResponseLike } from \"./types\";\n\n/**\n * @deprecated Use `ExitPreviewAPIRouteConfig` instead when `exitPreview()` is\n * used in a Pages Router API endpoint. `exitPreview()` does not require any\n * configuration when used in an App Router Route Handler.\n */\nexport type ExitPreviewConfig = ExitPreviewAPIRouteConfig;\n\n/**\n * Configuration for `exitPreview()` when used in a Pages Router API route.\n */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * **Only use this parameter in the Pages Directory (/pages).**\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 * **Only use this parameter in the Pages Directory (/pages).**\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\n * used in a Router Handler or an API route, depending on whether you are using\n * the App Router or Pages Router.\n *\n * @example Usage within an App Router Route Handler.\n *\n * ```typescript\n * // src/app/api/exit-preview/route.js\n *\n * import { exitPreview } from \"@prismicio/next\";\n *\n * export function GET() {\n * \treturn exitPreview();\n * }\n * ```\n *\n * @example Usage within a Pages Router API Route.\n *\n * ```typescript\n * // src/pages/api/exit-preview.js\n *\n * import { exitPreview } from \"@prismicio/next\";\n *\n * export default function handler(req, res) {\n * \texitPreview({ req, res });\n * }\n * ```\n */\nexport async function exitPreview(): Promise<Response>;\nexport async function exitPreview(\n\tconfig: ExitPreviewAPIRouteConfig,\n): Promise<void>;\nexport async function exitPreview(\n\tconfig?: ExitPreviewAPIRouteConfig,\n): Promise<Response | void> {\n\tif (config?.res) {\n\t\t// Assume Preview Mode is being used.\n\n\t\tconfig.res.clearPreviewData();\n\n\t\t// `Cache-Control` header is used to prevent CDN-level caching.\n\t\tconfig.res.setHeader(\"Cache-Control\", \"no-store\");\n\n\t\tconfig.res.json({ success: true });\n\n\t\treturn;\n\t} else {\n\t\t// Assume Draft Mode is being used.\n\n\t\t(await draftMode()).disable();\n\n\t\t// `Cache-Control` header is used to prevent CDN-level caching.\n\t\treturn new Response(JSON.stringify({ success: true }), {\n\t\t\theaders: {\n\t\t\t\t\"Cache-Control\": \"no-store\",\n\t\t\t},\n\t\t});\n\t}\n}\n"],"names":["draftMode"],"mappings":";;;AAmEA,eAAsB,YACrB,QAAkC;AAElC,MAAI,iCAAQ,KAAK;AAGhB,WAAO,IAAI;AAGJ,WAAA,IAAI,UAAU,iBAAiB,UAAU;AAEhD,WAAO,IAAI,KAAK,EAAE,SAAS,KAAM,CAAA;AAEjC;AAAA,EAAA,OACM;AAGL,KAAA,MAAMA,QAAAA,aAAa;AAGb,WAAA,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,KAAA,CAAM,GAAG;AAAA,MACtD,SAAS;AAAA,QACR,iBAAiB;AAAA,MACjB;AAAA,IAAA,CACD;AAAA,EACD;AACF;;"}
|
package/dist/imgixLoader.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const imgixUrlBuilder = require("imgix-url-builder");
|
|
4
|
-
const imgixLoader = (args) => {
|
|
5
|
-
const url = new URL(args.src);
|
|
6
|
-
const params = {
|
|
7
|
-
fit: url.searchParams.get("fit") || "max",
|
|
8
|
-
w: args.width,
|
|
9
|
-
h: void 0
|
|
10
|
-
};
|
|
11
|
-
if (args.quality) {
|
|
12
|
-
params.q = args.quality;
|
|
13
|
-
}
|
|
14
|
-
return imgixUrlBuilder.buildURL(args.src, params);
|
|
15
|
-
};
|
|
16
|
-
exports.imgixLoader = imgixLoader;
|
|
17
|
-
//# sourceMappingURL=imgixLoader.cjs.map
|
package/dist/imgixLoader.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"imgixLoader.cjs","sources":["../../src/imgixLoader.ts"],"sourcesContent":["import { ImageLoaderProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\n\n/**\n * A `next/image` loader for Imgix, which Prismic uses, with an optional\n * collection of default Imgix parameters.\n *\n * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader\n * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering\n */\nexport const imgixLoader = (args: ImageLoaderProps): string => {\n\tconst url = new URL(args.src);\n\n\tconst params: ImgixURLParams = {\n\t\tfit: (url.searchParams.get(\"fit\") as ImgixURLParams[\"fit\"]) || \"max\",\n\t\tw: args.width,\n\t\th: undefined,\n\t};\n\n\tif (args.quality) {\n\t\tparams.q = args.quality;\n\t}\n\n\treturn buildURL(args.src, params);\n};\n"],"names":["buildURL"],"mappings":";;;AAUa,MAAA,cAAc,CAAC,SAAkC;AAC7D,QAAM,MAAM,IAAI,IAAI,KAAK,GAAG;AAE5B,QAAM,SAAyB;AAAA,IAC9B,KAAM,IAAI,aAAa,IAAI,KAAK,KAA+B;AAAA,IAC/D,GAAG,KAAK;AAAA,IACR,GAAG;AAAA,EAAA;AAGJ,MAAI,KAAK,SAAS;AACjB,WAAO,IAAI,KAAK;AAAA,EAChB;AAEM,SAAAA,yBAAS,KAAK,KAAK,MAAM;AACjC;;"}
|
package/dist/index.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const setPreviewData = require("./setPreviewData.cjs");
|
|
4
|
-
const exitPreview = require("./exitPreview.cjs");
|
|
5
|
-
const PrismicPreview = require("./PrismicPreview.cjs");
|
|
6
|
-
const PrismicNextLink = require("./PrismicNextLink.cjs");
|
|
7
|
-
const enableAutoPreviews = require("./enableAutoPreviews.cjs");
|
|
8
|
-
const redirectToPreviewURL = require("./redirectToPreviewURL.cjs");
|
|
9
|
-
const createLocaleRedirect = require("./createLocaleRedirect.cjs");
|
|
10
|
-
const PrismicNextImage = require("./PrismicNextImage.cjs");
|
|
11
|
-
const imgixLoader = require("./imgixLoader.cjs");
|
|
12
|
-
exports.setPreviewData = setPreviewData.setPreviewData;
|
|
13
|
-
exports.exitPreview = exitPreview.exitPreview;
|
|
14
|
-
exports.PrismicPreview = PrismicPreview.PrismicPreview;
|
|
15
|
-
exports.PrismicNextLink = PrismicNextLink.PrismicNextLink;
|
|
16
|
-
exports.enableAutoPreviews = enableAutoPreviews.enableAutoPreviews;
|
|
17
|
-
exports.redirectToPreviewURL = redirectToPreviewURL.redirectToPreviewURL;
|
|
18
|
-
exports.createLocaleRedirect = createLocaleRedirect.createLocaleRedirect;
|
|
19
|
-
exports.PrismicNextImage = PrismicNextImage.PrismicNextImage;
|
|
20
|
-
exports.imgixLoader = imgixLoader.imgixLoader;
|
|
21
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
package/dist/lib/devMsg.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const _package = require("../package.json.cjs");
|
|
4
|
-
const devMsg = (slug) => {
|
|
5
|
-
return `https://prismic.dev/msg/next/v${_package.version}/${slug}`;
|
|
6
|
-
};
|
|
7
|
-
exports.devMsg = devMsg;
|
|
8
|
-
//# sourceMappingURL=devMsg.cjs.map
|
package/dist/lib/devMsg.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.cjs","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 *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/next/v1.2.3/missing-param.md\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string) => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"names":["version"],"mappings":";;;AAiBa,MAAA,SAAS,CAAC,SAAgB;AAC/B,SAAA,iCAAiCA,SAAAA,OAAO,IAAI,IAAI;AACxD;;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const getPreviewCookieRepositoryName = (previewCookie) => {
|
|
4
|
-
return (decodeURIComponent(previewCookie).match(/"([^"]+)\.prismic\.io"/) || [])[1];
|
|
5
|
-
};
|
|
6
|
-
exports.getPreviewCookieRepositoryName = getPreviewCookieRepositoryName;
|
|
7
|
-
//# sourceMappingURL=getPreviewCookieRepositoryName.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPreviewCookieRepositoryName.cjs","sources":["../../../src/lib/getPreviewCookieRepositoryName.ts"],"sourcesContent":["/**\n * Extracts preview reference repo name from stringified Prismic preview cookie\n *\n * @param previewCookie - The Prismic preview cookie.\n *\n * @returns The repository name for the Prismic preview cookie. If the cookie\n * represents an inactive preview session, `undefined` will be returned.\n */\nexport const getPreviewCookieRepositoryName = (\n\tpreviewCookie: string,\n): string | undefined => {\n\treturn (decodeURIComponent(previewCookie).match(/\"([^\"]+)\\.prismic\\.io\"/) ||\n\t\t[])[1];\n};\n"],"names":[],"mappings":";;AAQa,MAAA,iCAAiC,CAC7C,kBACuB;AACf,UAAA,mBAAmB,aAAa,EAAE,MAAM,wBAAwB,KACvE,CAAA,GAAI,CAAC;AACP;;"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts preview reference repo name from stringified Prismic preview cookie
|
|
3
|
-
*
|
|
4
|
-
* @param previewCookie - The Prismic preview cookie.
|
|
5
|
-
*
|
|
6
|
-
* @returns The repository name for the Prismic preview cookie. If the cookie
|
|
7
|
-
* represents an inactive preview session, `undefined` will be returned.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getPreviewCookieRepositoryName: (previewCookie: string) => string | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPreviewCookieRepositoryName.js","sources":["../../../src/lib/getPreviewCookieRepositoryName.ts"],"sourcesContent":["/**\n * Extracts preview reference repo name from stringified Prismic preview cookie\n *\n * @param previewCookie - The Prismic preview cookie.\n *\n * @returns The repository name for the Prismic preview cookie. If the cookie\n * represents an inactive preview session, `undefined` will be returned.\n */\nexport const getPreviewCookieRepositoryName = (\n\tpreviewCookie: string,\n): string | undefined => {\n\treturn (decodeURIComponent(previewCookie).match(/\"([^\"]+)\\.prismic\\.io\"/) ||\n\t\t[])[1];\n};\n"],"names":[],"mappings":"AAQa,MAAA,iCAAiC,CAC7C,kBACuB;AACf,UAAA,mBAAmB,aAAa,EAAE,MAAM,wBAAwB,KACvE,CAAA,GAAI,CAAC;AACP;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const cookie = require('./../_node_modules/@prismicio/client/dist/cookie.cjs');
|
|
4
|
-
const readValue = (value) => {
|
|
5
|
-
return value.replace(/%3B/g, ";");
|
|
6
|
-
};
|
|
7
|
-
const getPrismicPreviewCookie = (cookieJar) => {
|
|
8
|
-
const cookies = cookieJar.split("; ");
|
|
9
|
-
let value;
|
|
10
|
-
for (const cookie$1 of cookies) {
|
|
11
|
-
const parts = cookie$1.split("=");
|
|
12
|
-
const name = readValue(parts[0]).replace(/%3D/g, "=");
|
|
13
|
-
if (name === cookie.preview) {
|
|
14
|
-
value = readValue(parts.slice(1).join("="));
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return value;
|
|
19
|
-
};
|
|
20
|
-
exports.getPrismicPreviewCookie = getPrismicPreviewCookie;
|
|
21
|
-
//# sourceMappingURL=getPrismicPreviewCookie.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPrismicPreviewCookie.cjs","sources":["../../../src/lib/getPrismicPreviewCookie.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\n};\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPrismicPreviewCookie = (\n\tcookieJar: string,\n): string | undefined => {\n\tconst cookies = cookieJar.split(\"; \");\n\n\tlet value: string | undefined;\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\");\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\");\n\n\t\tif (name === prismic.cookie.preview) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"));\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n};\n"],"names":["cookie","prismic.cookie.preview"],"mappings":";;;AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,0BAA0B,CACtC,cACuB;AACjB,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAWA,YAAU,SAAS;AACvB,UAAA,QAAQA,SAAO,MAAM,GAAG;AACxB,UAAA,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEhD,QAAA,SAASC,OAAAA,SAAwB;AACpC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACA;AAAA,EACD;AAEM,SAAA;AACR;;"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the value of a cookie from a given cookie store.
|
|
3
|
-
*
|
|
4
|
-
* @param cookieJar - The stringified cookie store from which to read the
|
|
5
|
-
* cookie.
|
|
6
|
-
*
|
|
7
|
-
* @returns The value of the cookie, if it exists.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getPrismicPreviewCookie: (cookieJar: string) => string | undefined;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { preview } from './../_node_modules/@prismicio/client/dist/cookie.js';
|
|
2
|
-
const readValue = (value) => {
|
|
3
|
-
return value.replace(/%3B/g, ";");
|
|
4
|
-
};
|
|
5
|
-
const getPrismicPreviewCookie = (cookieJar) => {
|
|
6
|
-
const cookies = cookieJar.split("; ");
|
|
7
|
-
let value;
|
|
8
|
-
for (const cookie of cookies) {
|
|
9
|
-
const parts = cookie.split("=");
|
|
10
|
-
const name = readValue(parts[0]).replace(/%3D/g, "=");
|
|
11
|
-
if (name === preview) {
|
|
12
|
-
value = readValue(parts.slice(1).join("="));
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return value;
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
getPrismicPreviewCookie
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=getPrismicPreviewCookie.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPrismicPreviewCookie.js","sources":["../../../src/lib/getPrismicPreviewCookie.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\n};\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPrismicPreviewCookie = (\n\tcookieJar: string,\n): string | undefined => {\n\tconst cookies = cookieJar.split(\"; \");\n\n\tlet value: string | undefined;\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\");\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\");\n\n\t\tif (name === prismic.cookie.preview) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"));\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n};\n"],"names":["prismic.cookie.preview"],"mappings":";AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,0BAA0B,CACtC,cACuB;AACjB,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAW,UAAU,SAAS;AACvB,UAAA,QAAQ,OAAO,MAAM,GAAG;AACxB,UAAA,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEhD,QAAA,SAASA,SAAwB;AACpC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACA;AAAA,EACD;AAEM,SAAA;AACR;"}
|
package/dist/package.json.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const navigation = require("next/navigation");
|
|
4
|
-
const headers = require("next/headers");
|
|
5
|
-
const cookie = require('./_node_modules/@prismicio/client/dist/cookie.cjs');
|
|
6
|
-
async function redirectToPreviewURL(config) {
|
|
7
|
-
const basePath = config.basePath || "";
|
|
8
|
-
const request = "request" in config ? config.request : config.req;
|
|
9
|
-
config.client.enableAutoPreviewsFromReq(request);
|
|
10
|
-
const previewUrl = await config.client.resolvePreviewURL({
|
|
11
|
-
linkResolver: config.linkResolver,
|
|
12
|
-
defaultURL: config.defaultURL || "/"
|
|
13
|
-
});
|
|
14
|
-
if ("nextUrl" in request) {
|
|
15
|
-
(await headers.draftMode()).enable();
|
|
16
|
-
const previewCookie = request.nextUrl.searchParams.get("token");
|
|
17
|
-
if (previewCookie) {
|
|
18
|
-
(await headers.cookies()).set(cookie.preview, previewCookie);
|
|
19
|
-
}
|
|
20
|
-
navigation.redirect(basePath + previewUrl);
|
|
21
|
-
} else {
|
|
22
|
-
if (!("res" in config)) {
|
|
23
|
-
throw new Error("[redirectToPreviewURL] The `res` object from the API route must be provided to `redirectToPreviewURL()`.");
|
|
24
|
-
}
|
|
25
|
-
config.res.redirect(basePath + previewUrl);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.redirectToPreviewURL = redirectToPreviewURL;
|
|
30
|
-
//# sourceMappingURL=redirectToPreviewURL.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redirectToPreviewURL.cjs","sources":["../../src/redirectToPreviewURL.ts"],"sourcesContent":["import { redirect } from \"next/navigation\";\nimport { cookies, draftMode } from \"next/headers\";\nimport * as prismic from \"@prismicio/client\";\n\nimport {\n\tNextApiRequestLike,\n\tNextApiResponseLike,\n\tNextRequestLike,\n} from \"./types\";\n\ntype RedirectToPreviewURLConfigBase = {\n\t/**\n\t * The Prismic client configured for the preview session's repository.\n\t */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<\n\t\tprismic.Client,\n\t\t\"enableAutoPreviewsFromReq\" | \"resolvePreviewURL\"\n\t>;\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: prismic.LinkResolverFunction;\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed\n\t * document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the\n\t * `defaultURL` option must _not_ include it. Instead, provide the `basePath`\n\t * property using the `basePath` option.\n\t */\n\tdefaultURL?: string;\n\n\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`.\n\t * This option can be omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath`\n\t * automatically. It must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string;\n};\n\nexport type RedirectToPreviewURLRouteHandlerConfig =\n\tRedirectToPreviewURLConfigBase & {\n\t\t/**\n\t\t * The `request` object from a Next.js Route Handler.\n\t\t *\n\t\t * @see Next.js Route Handler docs: \\<https://nextjs.org/docs/app/building-your-application/routing/route-handlers\\>\n\t\t */\n\t\trequest: NextRequestLike;\n\t};\n\nexport type RedirectToPreviewURLAPIEndpointConfig =\n\tRedirectToPreviewURLConfigBase & {\n\t\t/**\n\t\t * The `req` object from a Next.js API route.\n\t\t *\n\t\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t\t */\n\t\treq: NextApiRequestLike;\n\n\t\t/**\n\t\t * The `res` object from a Next.js API route.\n\t\t *\n\t\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t\t */\n\t\tres: NextApiResponseLike;\n\t};\n\nexport type RedirectToPreviewURLConfig =\n\t| RedirectToPreviewURLRouteHandlerConfig\n\t| RedirectToPreviewURLAPIEndpointConfig;\n\nexport async function redirectToPreviewURL(\n\tconfig: RedirectToPreviewURLRouteHandlerConfig,\n): Promise<never>;\nexport async function redirectToPreviewURL(\n\tconfig: RedirectToPreviewURLAPIEndpointConfig,\n): Promise<void>;\nexport async function redirectToPreviewURL(\n\tconfig: RedirectToPreviewURLConfig,\n): Promise<never | void> {\n\tconst basePath = config.basePath || \"\";\n\tconst request = \"request\" in config ? config.request : config.req;\n\n\tconfig.client.enableAutoPreviewsFromReq(request);\n\n\tconst previewUrl = await config.client.resolvePreviewURL({\n\t\tlinkResolver: config.linkResolver,\n\t\tdefaultURL: config.defaultURL || \"/\",\n\t});\n\n\tif (\"nextUrl\" in request) {\n\t\t(await draftMode()).enable();\n\n\t\t// Set the initial preview cookie, if available.\n\t\t// Setting the cookie here is necessary to support unpublished\n\t\t// previews. Without setting it here, the page will try to\n\t\t// render without the preview cookie, leading to a\n\t\t// PrismicNotFound error.\n\t\tconst previewCookie = request.nextUrl.searchParams.get(\"token\");\n\t\tif (previewCookie) {\n\t\t\t(await cookies()).set(prismic.cookie.preview, previewCookie);\n\t\t}\n\n\t\tredirect(basePath + previewUrl);\n\t} else {\n\t\tif (!(\"res\" in config)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[redirectToPreviewURL] The `res` object from the API route must be provided to `redirectToPreviewURL()`.\",\n\t\t\t);\n\t\t}\n\n\t\tconfig.res.redirect(basePath + previewUrl);\n\n\t\treturn;\n\t}\n}\n"],"names":["draftMode","cookies","prismic.cookie.preview","redirect"],"mappings":";;;;;AAuFA,eAAsB,qBACrB,QAAkC;AAE5B,QAAA,WAAW,OAAO,YAAY;AACpC,QAAM,UAAU,aAAa,SAAS,OAAO,UAAU,OAAO;AAEvD,SAAA,OAAO,0BAA0B,OAAO;AAE/C,QAAM,aAAa,MAAM,OAAO,OAAO,kBAAkB;AAAA,IACxD,cAAc,OAAO;AAAA,IACrB,YAAY,OAAO,cAAc;AAAA,EAAA,CACjC;AAED,MAAI,aAAa,SAAS;AACxB,KAAA,MAAMA,QAAAA,aAAa;AAOpB,UAAM,gBAAgB,QAAQ,QAAQ,aAAa,IAAI,OAAO;AAC9D,QAAI,eAAe;AAClB,OAAC,MAAMC,QAAAA,QAAS,GAAE,IAAIC,gBAAwB,aAAa;AAAA,IAC3D;AAEDC,wBAAS,WAAW,UAAU;AAAA,EAAA,OACxB;AACF,QAAA,EAAE,SAAS,SAAS;AACjB,YAAA,IAAI,MACT,0GAA0G;AAAA,IAE3G;AAEM,WAAA,IAAI,SAAS,WAAW,UAAU;AAEzC;AAAA,EACA;AACF;;"}
|
package/dist/setPreviewData.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const cookie = require('./_node_modules/@prismicio/client/dist/cookie.cjs');
|
|
4
|
-
function setPreviewData({ req, res }) {
|
|
5
|
-
const ref = req.query.token || req.cookies[cookie.preview];
|
|
6
|
-
if (ref) {
|
|
7
|
-
res.setPreviewData({ ref });
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.setPreviewData = setPreviewData;
|
|
11
|
-
//# sourceMappingURL=setPreviewData.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setPreviewData.cjs","sources":["../../src/setPreviewData.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { NextApiRequestLike, NextApiResponseLike } from \"./types\";\n\n/**\n * Configuration for `setPreviewData`.\n */\nexport type SetPreviewDataConfig = {\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 * **Only use this function in the Pages Directory (/pages).**\n *\n * Set Prismic preview data for Next.js's Preview Mode.\n */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[prismic.cookie.preview];\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref });\n\t}\n}\n"],"names":["prismic.cookie.preview"],"mappings":";;;SA4BgB,eAAe,EAAE,KAAK,OAA2B;AAC1D,QAAA,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,OAAAA,OAAsB;AAEjE,MAAI,KAAK;AACJ,QAAA,eAAe,EAAE,IAAA,CAAK;AAAA,EAC1B;AACF;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setPreviewData.js","sources":["../../src/setPreviewData.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { NextApiRequestLike, NextApiResponseLike } from \"./types\";\n\n/**\n * Configuration for `setPreviewData`.\n */\nexport type SetPreviewDataConfig = {\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 * **Only use this function in the Pages Directory (/pages).**\n *\n * Set Prismic preview data for Next.js's Preview Mode.\n */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[prismic.cookie.preview];\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref });\n\t}\n}\n"],"names":["prismic.cookie.preview"],"mappings":";SA4BgB,eAAe,EAAE,KAAK,OAA2B;AAC1D,QAAA,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,OAAsB;AAEjE,MAAI,KAAK;AACJ,QAAA,eAAe,EAAE,IAAA,CAAK;AAAA,EAC1B;AACF;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts preview reference repo name from stringified Prismic preview cookie
|
|
3
|
-
*
|
|
4
|
-
* @param previewCookie - The Prismic preview cookie.
|
|
5
|
-
*
|
|
6
|
-
* @returns The repository name for the Prismic preview cookie. If the cookie
|
|
7
|
-
* represents an inactive preview session, `undefined` will be returned.
|
|
8
|
-
*/
|
|
9
|
-
export const getPreviewCookieRepositoryName = (
|
|
10
|
-
previewCookie: string,
|
|
11
|
-
): string | undefined => {
|
|
12
|
-
return (decodeURIComponent(previewCookie).match(/"([^"]+)\.prismic\.io"/) ||
|
|
13
|
-
[])[1];
|
|
14
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as prismic from "@prismicio/client";
|
|
2
|
-
|
|
3
|
-
const readValue = (value: string): string => {
|
|
4
|
-
return value.replace(/%3B/g, ";");
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Returns the value of a cookie from a given cookie store.
|
|
9
|
-
*
|
|
10
|
-
* @param cookieJar - The stringified cookie store from which to read the
|
|
11
|
-
* cookie.
|
|
12
|
-
*
|
|
13
|
-
* @returns The value of the cookie, if it exists.
|
|
14
|
-
*/
|
|
15
|
-
export const getPrismicPreviewCookie = (
|
|
16
|
-
cookieJar: string,
|
|
17
|
-
): string | undefined => {
|
|
18
|
-
const cookies = cookieJar.split("; ");
|
|
19
|
-
|
|
20
|
-
let value: string | undefined;
|
|
21
|
-
|
|
22
|
-
for (const cookie of cookies) {
|
|
23
|
-
const parts = cookie.split("=");
|
|
24
|
-
const name = readValue(parts[0]).replace(/%3D/g, "=");
|
|
25
|
-
|
|
26
|
-
if (name === prismic.cookie.preview) {
|
|
27
|
-
value = readValue(parts.slice(1).join("="));
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return value;
|
|
33
|
-
};
|