@prismicio/next 2.0.1 → 2.0.2-canary.6f580fa

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.
Files changed (92) hide show
  1. package/dist/PrismicNextImage.cjs +66 -56
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +57 -0
  4. package/dist/PrismicNextLink.cjs +29 -21
  5. package/dist/PrismicNextLink.cjs.map +1 -1
  6. package/dist/PrismicNextLink.d.cts +54 -0
  7. package/dist/PrismicNextRichText.cjs +34 -0
  8. package/dist/PrismicNextRichText.cjs.map +1 -0
  9. package/dist/PrismicNextRichText.d.cts +11 -0
  10. package/dist/PrismicPreview.cjs +38 -36
  11. package/dist/PrismicPreview.cjs.map +1 -1
  12. package/dist/PrismicPreview.d.cts +36 -0
  13. package/dist/PrismicPreviewClient.cjs +71 -65
  14. package/dist/PrismicPreviewClient.cjs.map +1 -1
  15. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  16. package/dist/createLocaleRedirect.cjs +11 -5
  17. package/dist/createLocaleRedirect.cjs.map +1 -1
  18. package/dist/createLocaleRedirect.d.cts +14 -0
  19. package/dist/enableAutoPreviews.cjs +27 -48
  20. package/dist/enableAutoPreviews.cjs.map +1 -1
  21. package/dist/enableAutoPreviews.d.cts +18 -0
  22. package/dist/exitPreview.cjs +24 -32
  23. package/dist/exitPreview.cjs.map +1 -1
  24. package/dist/{exitPreview.d.ts → exitPreview.d.cts} +5 -1
  25. package/dist/imgixLoader.cjs +21 -14
  26. package/dist/imgixLoader.cjs.map +1 -1
  27. package/dist/{imgixLoader.d.ts → imgixLoader.d.cts} +7 -1
  28. package/dist/index.cjs +19 -19
  29. package/dist/index.d.cts +11 -0
  30. package/dist/lib/devMsg.cjs +22 -5
  31. package/dist/lib/devMsg.cjs.map +1 -1
  32. package/dist/lib/resolveDefaultExport.cjs +23 -4
  33. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  34. package/dist/package.cjs +12 -0
  35. package/dist/package.cjs.map +1 -0
  36. package/dist/pages/PrismicPreview.cjs +71 -59
  37. package/dist/pages/PrismicPreview.cjs.map +1 -1
  38. package/dist/pages/PrismicPreview.d.cts +36 -0
  39. package/dist/pages/enableAutoPreviews.cjs +21 -14
  40. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  41. package/dist/pages/enableAutoPreviews.d.cts +37 -0
  42. package/dist/pages/exitPreview.cjs +24 -7
  43. package/dist/pages/exitPreview.cjs.map +1 -1
  44. package/dist/pages/exitPreview.d.cts +38 -0
  45. package/dist/pages/redirectToPreviewURL.cjs +13 -13
  46. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  47. package/dist/pages/redirectToPreviewURL.d.cts +48 -0
  48. package/dist/pages/setPreviewData.cjs +10 -8
  49. package/dist/pages/setPreviewData.cjs.map +1 -1
  50. package/dist/pages/setPreviewData.d.cts +26 -0
  51. package/dist/pages/types.d.cts +36 -0
  52. package/dist/pages.cjs +21 -21
  53. package/dist/pages.d.cts +12 -0
  54. package/dist/redirectToPreviewURL.cjs +21 -43
  55. package/dist/redirectToPreviewURL.cjs.map +1 -1
  56. package/dist/redirectToPreviewURL.d.cts +33 -0
  57. package/dist/types.d.cts +31 -0
  58. package/package.json +34 -49
  59. package/src/PrismicNextImage.tsx +10 -6
  60. package/src/PrismicNextLink.tsx +5 -3
  61. package/src/PrismicNextRichText.tsx +41 -0
  62. package/src/PrismicPreviewClient.tsx +2 -3
  63. package/src/createLocaleRedirect.ts +1 -1
  64. package/src/imgixLoader.ts +3 -2
  65. package/src/index.ts +3 -0
  66. package/src/lib/devMsg.ts +1 -1
  67. package/src/pages/PrismicPreview.tsx +2 -1
  68. package/src/pages/index.ts +3 -0
  69. package/src/pages/types.ts +2 -3
  70. package/src/redirectToPreviewURL.ts +1 -1
  71. package/dist/PrismicNextImage.d.ts +0 -54
  72. package/dist/PrismicNextLink.d.ts +0 -125
  73. package/dist/PrismicPreview.d.ts +0 -31
  74. package/dist/PrismicPreviewClient.d.ts +0 -9
  75. package/dist/createLocaleRedirect.d.ts +0 -10
  76. package/dist/enableAutoPreviews.d.ts +0 -13
  77. package/dist/index.cjs.map +0 -1
  78. package/dist/index.d.ts +0 -15
  79. package/dist/lib/devMsg.d.ts +0 -16
  80. package/dist/lib/resolveDefaultExport.d.ts +0 -18
  81. package/dist/package.json.cjs +0 -5
  82. package/dist/package.json.cjs.map +0 -1
  83. package/dist/pages/PrismicPreview.d.ts +0 -31
  84. package/dist/pages/enableAutoPreviews.d.ts +0 -31
  85. package/dist/pages/exitPreview.d.ts +0 -33
  86. package/dist/pages/index.d.ts +0 -18
  87. package/dist/pages/redirectToPreviewURL.d.ts +0 -43
  88. package/dist/pages/setPreviewData.d.ts +0 -18
  89. package/dist/pages/types.d.ts +0 -30
  90. package/dist/pages.cjs.map +0 -1
  91. package/dist/redirectToPreviewURL.d.ts +0 -28
  92. package/dist/types.d.ts +0 -26
@@ -1,125 +0,0 @@
1
- import { ComponentProps } from "react";
2
- import Link from "next/link";
3
- import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
4
- export type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
5
- linkResolver?: LinkResolverFunction;
6
- rel?: string | AsLinkAttrsConfig["rel"];
7
- } & ({
8
- field: LinkField | null | undefined;
9
- document?: never;
10
- href?: never;
11
- } | {
12
- field?: never;
13
- document: PrismicDocument | null | undefined;
14
- href?: never;
15
- } | {
16
- field?: never;
17
- document?: never;
18
- href: ComponentProps<typeof Link>["href"];
19
- });
20
- export declare const PrismicNextLink: import("react").ForwardRefExoticComponent<(Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
21
- href: string | import("url").UrlObject;
22
- as?: string | import("url").UrlObject;
23
- replace?: boolean;
24
- scroll?: boolean;
25
- shallow?: boolean;
26
- passHref?: boolean;
27
- prefetch?: boolean | null;
28
- locale?: string | false;
29
- legacyBehavior?: boolean;
30
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
31
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
32
- onClick?: React.MouseEventHandler<HTMLAnchorElement>;
33
- }> & {
34
- href: string | import("url").UrlObject;
35
- as?: string | import("url").UrlObject;
36
- replace?: boolean;
37
- scroll?: boolean;
38
- shallow?: boolean;
39
- passHref?: boolean;
40
- prefetch?: boolean | null;
41
- locale?: string | false;
42
- legacyBehavior?: boolean;
43
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
44
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
45
- onClick?: React.MouseEventHandler<HTMLAnchorElement>;
46
- } & {
47
- children?: React.ReactNode | undefined;
48
- } & import("react").RefAttributes<HTMLAnchorElement>, "rel" | "field" | "document" | "href"> & {
49
- linkResolver?: LinkResolverFunction;
50
- rel?: string | AsLinkAttrsConfig["rel"];
51
- } & {
52
- field: LinkField | null | undefined;
53
- document?: never;
54
- href?: never;
55
- }, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
56
- href: string | import("url").UrlObject;
57
- as?: string | import("url").UrlObject;
58
- replace?: boolean;
59
- scroll?: boolean;
60
- shallow?: boolean;
61
- passHref?: boolean;
62
- prefetch?: boolean | null;
63
- locale?: string | false;
64
- legacyBehavior?: boolean;
65
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
66
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
67
- onClick?: React.MouseEventHandler<HTMLAnchorElement>;
68
- }> & {
69
- href: string | import("url").UrlObject;
70
- as?: string | import("url").UrlObject;
71
- replace?: boolean;
72
- scroll?: boolean;
73
- shallow?: boolean;
74
- passHref?: boolean;
75
- prefetch?: boolean | null;
76
- locale?: string | false;
77
- legacyBehavior?: boolean;
78
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
79
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
80
- onClick?: React.MouseEventHandler<HTMLAnchorElement>;
81
- } & {
82
- children?: React.ReactNode | undefined;
83
- } & import("react").RefAttributes<HTMLAnchorElement>, "rel" | "field" | "document" | "href"> & {
84
- linkResolver?: LinkResolverFunction;
85
- rel?: string | AsLinkAttrsConfig["rel"];
86
- } & {
87
- field?: never;
88
- document: PrismicDocument | null | undefined;
89
- href?: never;
90
- }, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
91
- href: string | import("url").UrlObject;
92
- as?: string | import("url").UrlObject;
93
- replace?: boolean;
94
- scroll?: boolean;
95
- shallow?: boolean;
96
- passHref?: boolean;
97
- prefetch?: boolean | null;
98
- locale?: string | false;
99
- legacyBehavior?: boolean;
100
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
101
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
102
- onClick?: React.MouseEventHandler<HTMLAnchorElement>;
103
- }> & {
104
- href: string | import("url").UrlObject;
105
- as?: string | import("url").UrlObject;
106
- replace?: boolean;
107
- scroll?: boolean;
108
- shallow?: boolean;
109
- passHref?: boolean;
110
- prefetch?: boolean | null;
111
- locale?: string | false;
112
- legacyBehavior?: boolean;
113
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
114
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
115
- onClick?: React.MouseEventHandler<HTMLAnchorElement>;
116
- } & {
117
- children?: React.ReactNode | undefined;
118
- } & import("react").RefAttributes<HTMLAnchorElement>, "rel" | "field" | "document" | "href"> & {
119
- linkResolver?: LinkResolverFunction;
120
- rel?: string | AsLinkAttrsConfig["rel"];
121
- } & {
122
- field?: never;
123
- document?: never;
124
- href: ComponentProps<typeof Link>["href"];
125
- }, "ref">) & import("react").RefAttributes<HTMLAnchorElement>>;
@@ -1,31 +0,0 @@
1
- import type { FC, ReactNode } from "react";
2
- /** Props for `<PrismicPreview>`. */
3
- export type PrismicPreviewProps = {
4
- /**
5
- * The name of your Prismic repository. A Prismic Toolbar will be registered
6
- * using this repository.
7
- */
8
- repositoryName: string;
9
- /**
10
- * The URL of your app's Prismic preview endpoint (default: `/api/preview`).
11
- * This URL will be fetched on preview update events.
12
- */
13
- updatePreviewURL?: string;
14
- /**
15
- * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
16
- * This URL will be fetched on preview exit events.
17
- */
18
- exitPreviewURL?: string;
19
- /** Children to render adjacent to the Prismic Toolbar. */
20
- children?: ReactNode;
21
- };
22
- /**
23
- * React component that sets up Prismic Previews using the Prismic Toolbar. When
24
- * the Prismic Toolbar send events to the browser, such as on preview updates
25
- * and exiting, this component will automatically refresh the page with the
26
- * changes.
27
- *
28
- * This component can be wrapped around your app or added anywhere in your app's
29
- * tree. It must be rendered on every page.
30
- */
31
- export declare const PrismicPreview: FC<PrismicPreviewProps>;
@@ -1,9 +0,0 @@
1
- import { FC } from "react";
2
- type PrismicPreviewClientProps = {
3
- repositoryName: string;
4
- isDraftMode: boolean;
5
- updatePreviewURL?: string;
6
- exitPreviewURL?: string;
7
- };
8
- export declare const PrismicPreviewClient: FC<PrismicPreviewClientProps>;
9
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * @deprecated `createLocaleRedirect()` has been removed due to performance
3
- * issues.
4
- */
5
- export declare function createLocaleRedirect(): void;
6
- /**
7
- * @deprecated `createLocaleRedirect()` has been removed due to performance
8
- * issues.
9
- */
10
- export type CreateLocaleRedirectConfig = never;
@@ -1,13 +0,0 @@
1
- import { type Client } from "@prismicio/client";
2
- /** Configuration for `enableAutoPreviews`. */
3
- export type EnableAutoPreviewsConfig = {
4
- /** Prismic client with which automatic previews will be enabled. */
5
- client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
6
- };
7
- /**
8
- * Configures a Prismic client to automatically query draft content during a
9
- * preview session.
10
- *
11
- * @param config - Configuration for the function.
12
- */
13
- export declare function enableAutoPreviews(config: EnableAutoPreviewsConfig): void;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
- export { exitPreview } from "./exitPreview";
2
- export { PrismicPreview } from "./PrismicPreview";
3
- export type { PrismicPreviewProps } from "./PrismicPreview";
4
- export { PrismicNextLink } from "./PrismicNextLink";
5
- export type { PrismicNextLinkProps } from "./PrismicNextLink";
6
- export { enableAutoPreviews } from "./enableAutoPreviews";
7
- export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
8
- export { redirectToPreviewURL } from "./redirectToPreviewURL";
9
- export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL";
10
- export { PrismicNextImage } from "./PrismicNextImage";
11
- export type { PrismicNextImageProps } from "./PrismicNextImage";
12
- export { imgixLoader } from "./imgixLoader";
13
- export type { CreateClientConfig } from "./types";
14
- export { createLocaleRedirect } from "./createLocaleRedirect";
15
- export type { CreateLocaleRedirectConfig } from "./createLocaleRedirect";
@@ -1,16 +0,0 @@
1
- /**
2
- * Returns a `prismic.dev/msg` URL for a given message slug.
3
- *
4
- * @example
5
- *
6
- * ```ts
7
- * devMsg("missing-param");
8
- * // => "https://prismic.dev/msg/next/v1.2.3/missing-param"
9
- * ```
10
- *
11
- * @param slug - Slug for the message. This corresponds to a Markdown file in
12
- * the Git repository's `/messages` directory.
13
- *
14
- * @returns The `prismic.dev/msg` URL for the given slug.
15
- */
16
- export declare const devMsg: (slug: string) => string;
@@ -1,18 +0,0 @@
1
- /**
2
- * Resolves a module's default export. The module may provide its default export
3
- * as a `default` property on an object. This happens when named and default
4
- * exports are mixed in modules.
5
- *
6
- * In ES Modules, mixing is fine since the module resolver can distinguish
7
- * default and named exports. In transpiled modules, however, all exports are
8
- * put into a single object, and the default export is provided at a property
9
- * called `default`.
10
- *
11
- * This helper is needed by Next.js uses CJS files with named and default
12
- * exports.
13
- *
14
- * This helper _should_ be a temporary hack until Next.js and Node.js resolve
15
- * their ESM difficulties. This will likely not be removed any time soon,
16
- * unfortunately.
17
- */
18
- export declare function resolveDefaultExport<T>(mod: T): T;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "2.0.1";
4
- exports.version = version;
5
- //# sourceMappingURL=package.json.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,31 +0,0 @@
1
- import { type ReactNode, FC } from "react";
2
- /** Props for `<PrismicPreview>`. */
3
- export type PrismicPreviewProps = {
4
- /**
5
- * The name of your Prismic repository. A Prismic Toolbar will be registered
6
- * using this repository.
7
- */
8
- repositoryName: string;
9
- /**
10
- * The URL of your app's Prismic preview endpoint (default: `/api/preview`).
11
- * This URL will be fetched on preview update events.
12
- */
13
- updatePreviewURL?: string;
14
- /**
15
- * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
16
- * This URL will be fetched on preview exit events.
17
- */
18
- exitPreviewURL?: string;
19
- /** Children to render adjacent to the Prismic Toolbar. */
20
- children?: ReactNode;
21
- };
22
- /**
23
- * React component that sets up Prismic Previews using the Prismic Toolbar. When
24
- * the Prismic Toolbar send events to the browser, such as on preview updates
25
- * and exiting, this component will automatically refresh the page with the
26
- * changes.
27
- *
28
- * This component can be wrapped around your app or added anywhere in your app's
29
- * tree. It must be rendered on every page.
30
- */
31
- export declare const PrismicPreview: FC<PrismicPreviewProps>;
@@ -1,31 +0,0 @@
1
- import type { PreviewData } from "next";
2
- import type { Client } from "@prismicio/client";
3
- import type { NextApiRequestLike } from "./types";
4
- /**
5
- * Configuration for `enableAutoPreviews`.
6
- *
7
- * @typeParam TPreviewData - Next.js preview data object.
8
- */
9
- export type EnableAutoPreviewsConfig = {
10
- /** Prismic client with which automatic previews will be enabled. */
11
- client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
12
- /**
13
- * The `previewData` object provided in the `getStaticProps()` or
14
- * `getServerSideProps()` context object.
15
- */
16
- previewData?: PreviewData;
17
- /**
18
- * The `req` object from a Next.js API route.
19
- *
20
- * @see Next.js API route docs: \<https://nextjs.org/docs/api-routes/introduction\>
21
- */
22
- req?: NextApiRequestLike;
23
- };
24
- /**
25
- * Configures a Prismic client to automatically query draft content during a
26
- * preview session. It either takes in a Next.js `getStaticProps` context object
27
- * or a Next.js API endpoint request object.
28
- *
29
- * @param config - Configuration for the function.
30
- */
31
- export declare function enableAutoPreviews(config: EnableAutoPreviewsConfig): void;
@@ -1,33 +0,0 @@
1
- import type { NextApiRequestLike, NextApiResponseLike } from "./types";
2
- /** Configuration for `exitPreview()`. */
3
- export type ExitPreviewAPIRouteConfig = {
4
- /**
5
- * The `req` object from a Next.js API route.
6
- *
7
- * @see Next.js API route docs: \<https://nextjs.org/docs/api-routes/introduction\>
8
- */
9
- req?: NextApiRequestLike;
10
- /**
11
- * The `res` object from a Next.js API route.
12
- *
13
- * @see Next.js API route docs: \<https://nextjs.org/docs/api-routes/introduction\>
14
- */
15
- res: NextApiResponseLike;
16
- };
17
- /**
18
- * Ends a Prismic preview session within a Next.js app. This function should be
19
- * used in an API route.
20
- *
21
- * @example
22
- *
23
- * ```typescript
24
- * // src/pages/api/exit-preview.js
25
- *
26
- * import { exitPreview } from "@prismicio/next";
27
- *
28
- * export default function handler(_req, res) {
29
- * return exitPreview({ res });
30
- * }
31
- * ```
32
- */
33
- export declare function exitPreview(config: ExitPreviewAPIRouteConfig): void;
@@ -1,18 +0,0 @@
1
- export { PrismicNextLink } from "../PrismicNextLink";
2
- export { type PrismicNextLinkProps } from "../PrismicNextLink";
3
- export { PrismicNextImage } from "../PrismicNextImage";
4
- export { type PrismicNextImageProps } from "../PrismicNextImage";
5
- export { imgixLoader } from "../imgixLoader";
6
- export { PrismicPreview } from "./PrismicPreview";
7
- export type { PrismicPreviewProps } from "./PrismicPreview";
8
- export { enableAutoPreviews } from "./enableAutoPreviews";
9
- export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
10
- export { redirectToPreviewURL } from "./redirectToPreviewURL";
11
- export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL";
12
- export { exitPreview } from "./exitPreview";
13
- export type { ExitPreviewAPIRouteConfig } from "./exitPreview";
14
- export { setPreviewData } from "./setPreviewData";
15
- export type { SetPreviewDataConfig } from "./setPreviewData";
16
- export type { CreateClientConfig } from "./types";
17
- export { createLocaleRedirect } from "../createLocaleRedirect";
18
- export type { CreateLocaleRedirectConfig } from "../createLocaleRedirect";
@@ -1,43 +0,0 @@
1
- import type { LinkResolverFunction, Client } from "@prismicio/client";
2
- import type { NextApiRequestLike, NextApiResponseLike } from "./types";
3
- export type RedirectToPreviewURLConfig = {
4
- /** The Prismic client configured for the preview session's repository. */
5
- client: Pick<Client, "resolvePreviewURL">;
6
- /**
7
- * The `req` object from a Next.js API route.
8
- *
9
- * @see Next.js API route docs: \<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\>
10
- */
11
- req: NextApiRequestLike;
12
- /**
13
- * The `res` object from a Next.js API route.
14
- *
15
- * @see Next.js API route docs: \<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\>
16
- */
17
- res: NextApiResponseLike;
18
- /**
19
- * A Link Resolver used to resolve the previewed document's URL.
20
- *
21
- * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
22
- */
23
- linkResolver?: LinkResolverFunction;
24
- /**
25
- * The default redirect URL if a URL cannot be determined for the previewed
26
- * document.
27
- *
28
- * **Note**: If you `next.config.js` file contains a `basePath`, the
29
- * `defaultURL` option must _not_ include it. Instead, provide the `basePath`
30
- * property using the `basePath` option.
31
- */
32
- defaultURL?: string;
33
- /**
34
- * The `basePath` for the Next.js app as it is defined in `next.config.js`.
35
- * This option can be omitted if the app does not have a `basePath`.
36
- *
37
- * @remarks
38
- * The Router Handler or API route is unable to detect the app's `basePath`
39
- * automatically. It must be provided to `redirectToPreviewURL()` manually.
40
- */
41
- basePath?: string;
42
- };
43
- export declare function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void>;
@@ -1,18 +0,0 @@
1
- import type { NextApiRequestLike, NextApiResponseLike } from "./types";
2
- /** Configuration for `setPreviewData`. */
3
- export type SetPreviewDataConfig = {
4
- /**
5
- * The `req` object from a Next.js API route.
6
- *
7
- * @see Next.js API route docs: \<https://nextjs.org/docs/api-routes/introduction\>
8
- */
9
- req: NextApiRequestLike;
10
- /**
11
- * The `res` object from a Next.js API route.
12
- *
13
- * @see Next.js API route docs: \<https://nextjs.org/docs/api-routes/introduction\>
14
- */
15
- res: NextApiResponseLike;
16
- };
17
- /** Set Prismic preview data for Next.js's Preview Mode. */
18
- export declare function setPreviewData({ req, res }: SetPreviewDataConfig): void;
@@ -1,30 +0,0 @@
1
- import type { ClientConfig } from "@prismicio/client";
2
- import { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
3
- /**
4
- * Configuration for creating a Prismic client with automatic preview support in
5
- * Next.js apps.
6
- */
7
- export type CreateClientConfig = ClientConfig & Pick<EnableAutoPreviewsConfig, "previewData" | "req">;
8
- /**
9
- * The minimal set of properties needed from `next`'s `NextApiRequest` type.
10
- *
11
- * This request type is only compatible with API routes defined in the `pages`
12
- * directory.
13
- */
14
- export type NextApiRequestLike = {
15
- query: Partial<Record<string, string | string[]>>;
16
- cookies: Partial<Record<string, string>>;
17
- };
18
- /**
19
- * The minimal set of properties needed from `next`'s `NextApiResponse` type.
20
- *
21
- * This request type is only compatible with API routes defined in the `pages`
22
- * directory.
23
- */
24
- export type NextApiResponseLike = {
25
- redirect(url: string): NextApiResponseLike;
26
- clearPreviewData(): NextApiResponseLike;
27
- setHeader(name: string, value: string | string[]): NextApiResponseLike;
28
- json(body: any): void;
29
- setPreviewData(data: object | string): NextApiResponseLike;
30
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
@@ -1,28 +0,0 @@
1
- import { type Client, type LinkResolverFunction } from "@prismicio/client";
2
- import { NextRequestLike } from "./types";
3
- export type RedirectToPreviewURLConfig = {
4
- /** The Prismic client configured for the preview session's repository. */
5
- client: Pick<Client, "resolvePreviewURL">;
6
- /**
7
- * The `request` object from a Next.js Route Handler.
8
- *
9
- * @see Next.js Route Handler docs: \<https://nextjs.org/docs/app/building-your-application/routing/route-handlers\>
10
- */
11
- request: NextRequestLike;
12
- /**
13
- * A Link Resolver used to resolve the previewed document's URL.
14
- *
15
- * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
16
- */
17
- linkResolver?: LinkResolverFunction;
18
- /**
19
- * The default redirect URL if a URL cannot be determined for the previewed
20
- * document.
21
- *
22
- * **Note**: If you `next.config.js` file contains a `basePath`, the
23
- * `defaultURL` option must _not_ include it. Instead, provide the `basePath`
24
- * property using the `basePath` option.
25
- */
26
- defaultURL?: string;
27
- };
28
- export declare function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<never>;
package/dist/types.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import type { ClientConfig } from "@prismicio/client";
2
- declare module "@prismicio/client" {
3
- interface RequestInitLike {
4
- next?: RequestInit["next"];
5
- }
6
- }
7
- /** @deprecated Use `@prismicio/client`'s `ClientConfig`. */
8
- export type CreateClientConfig = ClientConfig;
9
- /**
10
- * The minimal set of properties needed from `next`'s `NextRequest` type.
11
- *
12
- * This request type is only compatible with Route Handlers defined in the `app`
13
- * directory.
14
- */
15
- export type NextRequestLike = {
16
- headers: {
17
- get(name: string): string | null;
18
- };
19
- url: string;
20
- nextUrl: {
21
- pathname: string;
22
- searchParams: {
23
- get(name: string): string | null;
24
- };
25
- };
26
- };