@prismicio/next 0.1.6-alpha.0 → 0.1.6-alpha.1
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/PrismicNextImage.d.ts +48 -48
- package/dist/PrismicPreview.d.ts +42 -42
- package/dist/enableAutoPreviews.d.ts +38 -38
- package/dist/exitPreview.d.ts +34 -34
- package/dist/index.d.ts +13 -13
- package/dist/lib/__PRODUCTION__.d.ts +7 -7
- package/dist/lib/devMsg.d.ts +16 -16
- package/dist/lib/getPreviewCookieRepositoryName.d.ts +9 -9
- package/dist/lib/getPrismicPreviewCookie.d.ts +9 -9
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/redirectToPreviewURL.d.ts +59 -59
- package/dist/setPreviewData.d.ts +29 -29
- package/dist/types.d.ts +21 -21
- package/package.json +7 -7
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ImageProps } from "next/image";
|
|
3
|
-
import { ImgixURLParams } from "imgix-url-builder";
|
|
4
|
-
import * as prismicT from "@prismicio/types";
|
|
5
|
-
export declare type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "width" | "height"> & {
|
|
6
|
-
/**
|
|
7
|
-
* The Prismic Image field or thumbnail to render.
|
|
8
|
-
*/
|
|
9
|
-
field: prismicT.ImageFieldImage | null | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* An object of Imgix URL API parameters to transform the image.
|
|
12
|
-
*
|
|
13
|
-
* @see https://docs.imgix.com/apis/rendering
|
|
14
|
-
*/
|
|
15
|
-
imgixParams?: ImgixURLParams;
|
|
16
|
-
/**
|
|
17
|
-
* Declare an image as decorative by providing `alt=""`.
|
|
18
|
-
*
|
|
19
|
-
* See:
|
|
20
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
21
|
-
*/
|
|
22
|
-
alt?: "";
|
|
23
|
-
/**
|
|
24
|
-
* Declare an image as decorative only if the Image field does not have
|
|
25
|
-
* alternative text by providing `fallbackAlt=""`.
|
|
26
|
-
*
|
|
27
|
-
* See:
|
|
28
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
29
|
-
*/
|
|
30
|
-
fallbackAlt?: "";
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* React component that renders an image from a Prismic Image field or one of
|
|
34
|
-
* its thumbnails using `next/image`. It will automatically set the `alt`
|
|
35
|
-
* attribute using the Image field's `alt` property.
|
|
36
|
-
*
|
|
37
|
-
* It uses an Imgix URL-based loader by default. A custom loader can be provided
|
|
38
|
-
* with the `loader` prop. If you would like to use the Next.js Image
|
|
39
|
-
* Optimization API instead, set `loader={undefined}`.
|
|
40
|
-
*
|
|
41
|
-
* @param props - Props for the component.
|
|
42
|
-
*
|
|
43
|
-
* @returns A responsive image component using `next/image` for the given Image
|
|
44
|
-
* field.
|
|
45
|
-
*
|
|
46
|
-
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
47
|
-
*/
|
|
48
|
-
export declare const PrismicNextImage: ({ field, imgixParams, alt, fallbackAlt, layout, ...restProps }: PrismicNextImageProps) => JSX.Element | null;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ImageProps } from "next/image";
|
|
3
|
+
import { ImgixURLParams } from "imgix-url-builder";
|
|
4
|
+
import * as prismicT from "@prismicio/types";
|
|
5
|
+
export declare type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "width" | "height"> & {
|
|
6
|
+
/**
|
|
7
|
+
* The Prismic Image field or thumbnail to render.
|
|
8
|
+
*/
|
|
9
|
+
field: prismicT.ImageFieldImage | null | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
12
|
+
*
|
|
13
|
+
* @see https://docs.imgix.com/apis/rendering
|
|
14
|
+
*/
|
|
15
|
+
imgixParams?: ImgixURLParams;
|
|
16
|
+
/**
|
|
17
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
18
|
+
*
|
|
19
|
+
* See:
|
|
20
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
21
|
+
*/
|
|
22
|
+
alt?: "";
|
|
23
|
+
/**
|
|
24
|
+
* Declare an image as decorative only if the Image field does not have
|
|
25
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
26
|
+
*
|
|
27
|
+
* See:
|
|
28
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
29
|
+
*/
|
|
30
|
+
fallbackAlt?: "";
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* React component that renders an image from a Prismic Image field or one of
|
|
34
|
+
* its thumbnails using `next/image`. It will automatically set the `alt`
|
|
35
|
+
* attribute using the Image field's `alt` property.
|
|
36
|
+
*
|
|
37
|
+
* It uses an Imgix URL-based loader by default. A custom loader can be provided
|
|
38
|
+
* with the `loader` prop. If you would like to use the Next.js Image
|
|
39
|
+
* Optimization API instead, set `loader={undefined}`.
|
|
40
|
+
*
|
|
41
|
+
* @param props - Props for the component.
|
|
42
|
+
*
|
|
43
|
+
* @returns A responsive image component using `next/image` for the given Image
|
|
44
|
+
* field.
|
|
45
|
+
*
|
|
46
|
+
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
47
|
+
*/
|
|
48
|
+
export declare const PrismicNextImage: ({ field, imgixParams, alt, fallbackAlt, layout, ...restProps }: PrismicNextImageProps) => JSX.Element | null;
|
package/dist/PrismicPreview.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Props for `<PrismicPreview>`.
|
|
4
|
-
*/
|
|
5
|
-
export declare type PrismicPreviewProps = {
|
|
6
|
-
/**
|
|
7
|
-
* The name of your Prismic repository. A Prismic Toolbar will be registered
|
|
8
|
-
* using this repository.
|
|
9
|
-
*/
|
|
10
|
-
repositoryName: string;
|
|
11
|
-
/**
|
|
12
|
-
* The URL of your app's Prismic preview endpoint (default: `/api/preview`).
|
|
13
|
-
* This URL will be fetched on preview update events.
|
|
14
|
-
*
|
|
15
|
-
* **Note**: If your `next.config.js` file contains a `basePath`, it is
|
|
16
|
-
* automatically included.
|
|
17
|
-
*/
|
|
18
|
-
updatePreviewURL?: string;
|
|
19
|
-
/**
|
|
20
|
-
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
21
|
-
* This URL will be fetched on preview exit events.
|
|
22
|
-
*
|
|
23
|
-
* **Note**: If your `next.config.js` file contains a `basePath`, it is
|
|
24
|
-
* automatically included.
|
|
25
|
-
*/
|
|
26
|
-
exitPreviewURL?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar
|
|
29
|
-
* will be rendered last.
|
|
30
|
-
*/
|
|
31
|
-
children?: React.ReactNode;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
35
|
-
* the Prismic Toolbar send events to the browser, such as on preview updates
|
|
36
|
-
* and exiting, this component will automatically update the Next.js preview
|
|
37
|
-
* cookie and refresh the page.
|
|
38
|
-
*
|
|
39
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
40
|
-
* tree. It must be rendered on every page.
|
|
41
|
-
*/
|
|
42
|
-
export declare function PrismicPreview({ repositoryName, children, updatePreviewURL, exitPreviewURL, }: PrismicPreviewProps): JSX.Element;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Props for `<PrismicPreview>`.
|
|
4
|
+
*/
|
|
5
|
+
export declare type PrismicPreviewProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The name of your Prismic repository. A Prismic Toolbar will be registered
|
|
8
|
+
* using this repository.
|
|
9
|
+
*/
|
|
10
|
+
repositoryName: string;
|
|
11
|
+
/**
|
|
12
|
+
* The URL of your app's Prismic preview endpoint (default: `/api/preview`).
|
|
13
|
+
* This URL will be fetched on preview update events.
|
|
14
|
+
*
|
|
15
|
+
* **Note**: If your `next.config.js` file contains a `basePath`, it is
|
|
16
|
+
* automatically included.
|
|
17
|
+
*/
|
|
18
|
+
updatePreviewURL?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
21
|
+
* This URL will be fetched on preview exit events.
|
|
22
|
+
*
|
|
23
|
+
* **Note**: If your `next.config.js` file contains a `basePath`, it is
|
|
24
|
+
* automatically included.
|
|
25
|
+
*/
|
|
26
|
+
exitPreviewURL?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar
|
|
29
|
+
* will be rendered last.
|
|
30
|
+
*/
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
35
|
+
* the Prismic Toolbar send events to the browser, such as on preview updates
|
|
36
|
+
* and exiting, this component will automatically update the Next.js preview
|
|
37
|
+
* cookie and refresh the page.
|
|
38
|
+
*
|
|
39
|
+
* This component can be wrapped around your app or added anywhere in your app's
|
|
40
|
+
* tree. It must be rendered on every page.
|
|
41
|
+
*/
|
|
42
|
+
export declare function PrismicPreview({ repositoryName, children, updatePreviewURL, exitPreviewURL, }: PrismicPreviewProps): JSX.Element;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { PreviewData } from "next";
|
|
2
|
-
import { Client, HttpRequestLike } from "@prismicio/client";
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for `enableAutoPreviews`.
|
|
5
|
-
*
|
|
6
|
-
* @typeParam TPreviewData - Next.js preview data object.
|
|
7
|
-
*/
|
|
8
|
-
export declare type EnableAutoPreviewsConfig<TPreviewData extends PreviewData = PreviewData> = {
|
|
9
|
-
/**
|
|
10
|
-
* Prismic client with which automatic previews will be enabled.
|
|
11
|
-
*/
|
|
12
|
-
client: Client;
|
|
13
|
-
} & ({
|
|
14
|
-
/**
|
|
15
|
-
* A Next.js context object (such as the context object from
|
|
16
|
-
* `getStaticProps` or `getServerSideProps`).
|
|
17
|
-
*
|
|
18
|
-
* Pass a `context` object when using `enableAutoPreviews` outside a
|
|
19
|
-
* Next.js API endpoint.
|
|
20
|
-
*/
|
|
21
|
-
previewData?: TPreviewData;
|
|
22
|
-
} | {
|
|
23
|
-
/**
|
|
24
|
-
* A Next.js API endpoint request object.
|
|
25
|
-
*
|
|
26
|
-
* Pass a `req` object when using `enableAutoPreviews` in a Next.js API
|
|
27
|
-
* endpoint.
|
|
28
|
-
*/
|
|
29
|
-
req?: HttpRequestLike;
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Configures a Prismic client to automatically query draft content during a
|
|
33
|
-
* preview session. It either takes in a Next.js `getStaticProps` context object
|
|
34
|
-
* or a Next.js API endpoint request object.
|
|
35
|
-
*
|
|
36
|
-
* @param config - Configuration for the function.
|
|
37
|
-
*/
|
|
38
|
-
export declare const enableAutoPreviews: <TPreviewData extends PreviewData>(config: EnableAutoPreviewsConfig<TPreviewData>) => void;
|
|
1
|
+
import { PreviewData } from "next";
|
|
2
|
+
import { Client, HttpRequestLike } from "@prismicio/client";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for `enableAutoPreviews`.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TPreviewData - Next.js preview data object.
|
|
7
|
+
*/
|
|
8
|
+
export declare type EnableAutoPreviewsConfig<TPreviewData extends PreviewData = PreviewData> = {
|
|
9
|
+
/**
|
|
10
|
+
* Prismic client with which automatic previews will be enabled.
|
|
11
|
+
*/
|
|
12
|
+
client: Client;
|
|
13
|
+
} & ({
|
|
14
|
+
/**
|
|
15
|
+
* A Next.js context object (such as the context object from
|
|
16
|
+
* `getStaticProps` or `getServerSideProps`).
|
|
17
|
+
*
|
|
18
|
+
* Pass a `context` object when using `enableAutoPreviews` outside a
|
|
19
|
+
* Next.js API endpoint.
|
|
20
|
+
*/
|
|
21
|
+
previewData?: TPreviewData;
|
|
22
|
+
} | {
|
|
23
|
+
/**
|
|
24
|
+
* A Next.js API endpoint request object.
|
|
25
|
+
*
|
|
26
|
+
* Pass a `req` object when using `enableAutoPreviews` in a Next.js API
|
|
27
|
+
* endpoint.
|
|
28
|
+
*/
|
|
29
|
+
req?: HttpRequestLike;
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Configures a Prismic client to automatically query draft content during a
|
|
33
|
+
* preview session. It either takes in a Next.js `getStaticProps` context object
|
|
34
|
+
* or a Next.js API endpoint request object.
|
|
35
|
+
*
|
|
36
|
+
* @param config - Configuration for the function.
|
|
37
|
+
*/
|
|
38
|
+
export declare const enableAutoPreviews: <TPreviewData extends PreviewData>(config: EnableAutoPreviewsConfig<TPreviewData>) => void;
|
package/dist/exitPreview.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import type { NextApiResponse, NextApiRequest } from "next";
|
|
2
|
-
/**
|
|
3
|
-
* Configuration for `exitPreview`.
|
|
4
|
-
*/
|
|
5
|
-
export declare type ExitPreviewConfig = {
|
|
6
|
-
/**
|
|
7
|
-
* The `req` object from a Next.js API route. This is given as a parameter to
|
|
8
|
-
* the API route.
|
|
9
|
-
*
|
|
10
|
-
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
11
|
-
*/
|
|
12
|
-
req: {
|
|
13
|
-
headers: NextApiRequest["headers"];
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* The `res` object from a Next.js API route. This is given as a parameter to
|
|
17
|
-
* the API route.
|
|
18
|
-
*
|
|
19
|
-
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
20
|
-
*/
|
|
21
|
-
res: {
|
|
22
|
-
clearPreviewData: NextApiResponse["clearPreviewData"];
|
|
23
|
-
status: NextApiResponse["status"];
|
|
24
|
-
json: NextApiResponse["json"];
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated - This property is no longer used. It can be deleted safely.
|
|
28
|
-
*/
|
|
29
|
-
exitPreviewURL?: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Exits Next.js's Preview Mode from within a Next.js API route.
|
|
33
|
-
*/
|
|
34
|
-
export declare function exitPreview(config: ExitPreviewConfig): void;
|
|
1
|
+
import type { NextApiResponse, NextApiRequest } from "next";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for `exitPreview`.
|
|
4
|
+
*/
|
|
5
|
+
export declare type ExitPreviewConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* The `req` object from a Next.js API route. This is given as a parameter to
|
|
8
|
+
* the API route.
|
|
9
|
+
*
|
|
10
|
+
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
11
|
+
*/
|
|
12
|
+
req: {
|
|
13
|
+
headers: NextApiRequest["headers"];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The `res` object from a Next.js API route. This is given as a parameter to
|
|
17
|
+
* the API route.
|
|
18
|
+
*
|
|
19
|
+
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
20
|
+
*/
|
|
21
|
+
res: {
|
|
22
|
+
clearPreviewData: NextApiResponse["clearPreviewData"];
|
|
23
|
+
status: NextApiResponse["status"];
|
|
24
|
+
json: NextApiResponse["json"];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated - This property is no longer used. It can be deleted safely.
|
|
28
|
+
*/
|
|
29
|
+
exitPreviewURL?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Exits Next.js's Preview Mode from within a Next.js API route.
|
|
33
|
+
*/
|
|
34
|
+
export declare function exitPreview(config: ExitPreviewConfig): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { setPreviewData } from "./setPreviewData";
|
|
2
|
-
export type { SetPreviewDataConfig } from "./setPreviewData";
|
|
3
|
-
export { exitPreview } from "./exitPreview";
|
|
4
|
-
export type { ExitPreviewConfig } from "./exitPreview";
|
|
5
|
-
export { PrismicPreview } from "./PrismicPreview";
|
|
6
|
-
export type { PrismicPreviewProps } from "./PrismicPreview";
|
|
7
|
-
export { enableAutoPreviews } from "./enableAutoPreviews";
|
|
8
|
-
export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
|
|
9
|
-
export { redirectToPreviewURL } from "./redirectToPreviewURL";
|
|
10
|
-
export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL";
|
|
11
|
-
export { PrismicNextImage } from "./PrismicNextImage";
|
|
12
|
-
export type { PrismicNextImageProps } from "./PrismicNextImage";
|
|
13
|
-
export type { CreateClientConfig } from "./types";
|
|
1
|
+
export { setPreviewData } from "./setPreviewData";
|
|
2
|
+
export type { SetPreviewDataConfig } from "./setPreviewData";
|
|
3
|
+
export { exitPreview } from "./exitPreview";
|
|
4
|
+
export type { ExitPreviewConfig } from "./exitPreview";
|
|
5
|
+
export { PrismicPreview } from "./PrismicPreview";
|
|
6
|
+
export type { PrismicPreviewProps } from "./PrismicPreview";
|
|
7
|
+
export { enableAutoPreviews } from "./enableAutoPreviews";
|
|
8
|
+
export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
|
|
9
|
+
export { redirectToPreviewURL } from "./redirectToPreviewURL";
|
|
10
|
+
export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL";
|
|
11
|
+
export { PrismicNextImage } from "./PrismicNextImage";
|
|
12
|
+
export type { PrismicNextImageProps } from "./PrismicNextImage";
|
|
13
|
+
export type { CreateClientConfig } from "./types";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `true` if in the production environment, `false` otherwise.
|
|
3
|
-
*
|
|
4
|
-
* This boolean can be used to perform actions only in development environments,
|
|
5
|
-
* such as logging.
|
|
6
|
-
*/
|
|
7
|
-
export declare const __PRODUCTION__: boolean;
|
|
1
|
+
/**
|
|
2
|
+
* `true` if in the production environment, `false` otherwise.
|
|
3
|
+
*
|
|
4
|
+
* This boolean can be used to perform actions only in development environments,
|
|
5
|
+
* such as logging.
|
|
6
|
+
*/
|
|
7
|
+
export declare const __PRODUCTION__: boolean;
|
package/dist/lib/devMsg.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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.md"
|
|
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
|
+
/**
|
|
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.md"
|
|
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,9 +1,9 @@
|
|
|
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
|
+
/**
|
|
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,9 +1,9 @@
|
|
|
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
|
+
/**
|
|
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;
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import type { Client } from "@prismicio/client";
|
|
2
|
-
import type { NextApiRequest, NextApiResponse } from "next";
|
|
3
|
-
import type { LinkResolverFunction } from "@prismicio/helpers";
|
|
4
|
-
/**
|
|
5
|
-
* Preview config for enabling previews with redirectToPreviewURL
|
|
6
|
-
*/
|
|
7
|
-
export declare type RedirectToPreviewURLConfig<TLinkResolverFunction extends LinkResolverFunction<any> = LinkResolverFunction> = {
|
|
8
|
-
/**
|
|
9
|
-
* The `req` object from a Next.js API route. This is given as a parameter to
|
|
10
|
-
* the API route.
|
|
11
|
-
*
|
|
12
|
-
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
13
|
-
*/
|
|
14
|
-
req: {
|
|
15
|
-
query: NextApiRequest["query"];
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* The `res` object from a Next.js API route. This is given as a parameter to
|
|
19
|
-
* the API route.
|
|
20
|
-
*
|
|
21
|
-
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
22
|
-
*/
|
|
23
|
-
res: {
|
|
24
|
-
redirect: NextApiResponse["redirect"];
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* The Prismic client configured for the preview session's repository.
|
|
28
|
-
*/
|
|
29
|
-
client: Client;
|
|
30
|
-
/**
|
|
31
|
-
* A Link Resolver used to resolve the previewed document's URL.
|
|
32
|
-
*
|
|
33
|
-
* @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
|
|
34
|
-
*/
|
|
35
|
-
linkResolver?: TLinkResolverFunction;
|
|
36
|
-
/**
|
|
37
|
-
* The default redirect URL if a URL cannot be determined for the previewed
|
|
38
|
-
* document.
|
|
39
|
-
*
|
|
40
|
-
* **Note**: If you `next.config.js` file contains a `basePath`, the
|
|
41
|
-
* `defaultURL` option must _not_ include it. Instead, provide the `basePath`
|
|
42
|
-
* property using the `basePath` option.
|
|
43
|
-
*/
|
|
44
|
-
defaultURL?: string;
|
|
45
|
-
/**
|
|
46
|
-
* The `basePath` for the Next.js app as it is defined in `next.config.js`.
|
|
47
|
-
* This option can be omitted if the app does not have a `basePath`.
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* The API route is unable to detect the app's `basePath` automatically. It
|
|
51
|
-
* must be provided to `redirectToPreviewURL()` manually.
|
|
52
|
-
*/
|
|
53
|
-
basePath?: string;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Redirects a user to the URL of a previewed Prismic document from within a
|
|
57
|
-
* Next.js API route.
|
|
58
|
-
*/
|
|
59
|
-
export declare function redirectToPreviewURL<TLinkResolverFunction extends LinkResolverFunction<any>>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void>;
|
|
1
|
+
import type { Client } from "@prismicio/client";
|
|
2
|
+
import type { NextApiRequest, NextApiResponse } from "next";
|
|
3
|
+
import type { LinkResolverFunction } from "@prismicio/helpers";
|
|
4
|
+
/**
|
|
5
|
+
* Preview config for enabling previews with redirectToPreviewURL
|
|
6
|
+
*/
|
|
7
|
+
export declare type RedirectToPreviewURLConfig<TLinkResolverFunction extends LinkResolverFunction<any> = LinkResolverFunction> = {
|
|
8
|
+
/**
|
|
9
|
+
* The `req` object from a Next.js API route. This is given as a parameter to
|
|
10
|
+
* the API route.
|
|
11
|
+
*
|
|
12
|
+
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
13
|
+
*/
|
|
14
|
+
req: {
|
|
15
|
+
query: NextApiRequest["query"];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The `res` object from a Next.js API route. This is given as a parameter to
|
|
19
|
+
* the API route.
|
|
20
|
+
*
|
|
21
|
+
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
22
|
+
*/
|
|
23
|
+
res: {
|
|
24
|
+
redirect: NextApiResponse["redirect"];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The Prismic client configured for the preview session's repository.
|
|
28
|
+
*/
|
|
29
|
+
client: Client;
|
|
30
|
+
/**
|
|
31
|
+
* A Link Resolver used to resolve the previewed document's URL.
|
|
32
|
+
*
|
|
33
|
+
* @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
|
|
34
|
+
*/
|
|
35
|
+
linkResolver?: TLinkResolverFunction;
|
|
36
|
+
/**
|
|
37
|
+
* The default redirect URL if a URL cannot be determined for the previewed
|
|
38
|
+
* document.
|
|
39
|
+
*
|
|
40
|
+
* **Note**: If you `next.config.js` file contains a `basePath`, the
|
|
41
|
+
* `defaultURL` option must _not_ include it. Instead, provide the `basePath`
|
|
42
|
+
* property using the `basePath` option.
|
|
43
|
+
*/
|
|
44
|
+
defaultURL?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The `basePath` for the Next.js app as it is defined in `next.config.js`.
|
|
47
|
+
* This option can be omitted if the app does not have a `basePath`.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* The API route is unable to detect the app's `basePath` automatically. It
|
|
51
|
+
* must be provided to `redirectToPreviewURL()` manually.
|
|
52
|
+
*/
|
|
53
|
+
basePath?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Redirects a user to the URL of a previewed Prismic document from within a
|
|
57
|
+
* Next.js API route.
|
|
58
|
+
*/
|
|
59
|
+
export declare function redirectToPreviewURL<TLinkResolverFunction extends LinkResolverFunction<any>>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void>;
|
package/dist/setPreviewData.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { NextApiResponse, NextApiRequest } from "next";
|
|
2
|
-
/**
|
|
3
|
-
* Configuration for `setPreviewData`.
|
|
4
|
-
*/
|
|
5
|
-
export declare type SetPreviewDataConfig = {
|
|
6
|
-
/**
|
|
7
|
-
* The `req` object from a Next.js API route. This is given as a parameter to
|
|
8
|
-
* the API route.
|
|
9
|
-
*
|
|
10
|
-
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
11
|
-
*/
|
|
12
|
-
req: {
|
|
13
|
-
query: NextApiRequest["query"];
|
|
14
|
-
cookies: NextApiRequest["cookies"];
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* The `res` object from a Next.js API route. This is given as a parameter to
|
|
18
|
-
* the API route.
|
|
19
|
-
*
|
|
20
|
-
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
21
|
-
*/
|
|
22
|
-
res: {
|
|
23
|
-
setPreviewData: NextApiResponse["setPreviewData"];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Set Prismic preview data for Next.js's Preview Mode.
|
|
28
|
-
*/
|
|
29
|
-
export declare function setPreviewData({ req, res }: SetPreviewDataConfig): void;
|
|
1
|
+
import { NextApiResponse, NextApiRequest } from "next";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for `setPreviewData`.
|
|
4
|
+
*/
|
|
5
|
+
export declare type SetPreviewDataConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* The `req` object from a Next.js API route. This is given as a parameter to
|
|
8
|
+
* the API route.
|
|
9
|
+
*
|
|
10
|
+
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
11
|
+
*/
|
|
12
|
+
req: {
|
|
13
|
+
query: NextApiRequest["query"];
|
|
14
|
+
cookies: NextApiRequest["cookies"];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The `res` object from a Next.js API route. This is given as a parameter to
|
|
18
|
+
* the API route.
|
|
19
|
+
*
|
|
20
|
+
* @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
|
|
21
|
+
*/
|
|
22
|
+
res: {
|
|
23
|
+
setPreviewData: NextApiResponse["setPreviewData"];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Set Prismic preview data for Next.js's Preview Mode.
|
|
28
|
+
*/
|
|
29
|
+
export declare function setPreviewData({ req, res }: SetPreviewDataConfig): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { PreviewData, NextApiRequest } from "next";
|
|
2
|
-
import type { ClientConfig } from "@prismicio/client";
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for creating a Prismic client with automatic preview support in
|
|
5
|
-
* Next.js apps.
|
|
6
|
-
*/
|
|
7
|
-
export declare type CreateClientConfig = {
|
|
8
|
-
/**
|
|
9
|
-
* Preview data coming from Next.js context object. This context object comes
|
|
10
|
-
* from `getStaticProps` or `getServerSideProps`.
|
|
11
|
-
*
|
|
12
|
-
* Pass `previewData` when using outside a Next.js API endpoint.
|
|
13
|
-
*/
|
|
14
|
-
previewData?: PreviewData;
|
|
15
|
-
/**
|
|
16
|
-
* A Next.js API endpoint request object.
|
|
17
|
-
*
|
|
18
|
-
* Pass a `req` object when using in a Next.js API endpoint.
|
|
19
|
-
*/
|
|
20
|
-
req?: NextApiRequest;
|
|
21
|
-
} & ClientConfig;
|
|
1
|
+
import type { PreviewData, NextApiRequest } from "next";
|
|
2
|
+
import type { ClientConfig } from "@prismicio/client";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for creating a Prismic client with automatic preview support in
|
|
5
|
+
* Next.js apps.
|
|
6
|
+
*/
|
|
7
|
+
export declare type CreateClientConfig = {
|
|
8
|
+
/**
|
|
9
|
+
* Preview data coming from Next.js context object. This context object comes
|
|
10
|
+
* from `getStaticProps` or `getServerSideProps`.
|
|
11
|
+
*
|
|
12
|
+
* Pass `previewData` when using outside a Next.js API endpoint.
|
|
13
|
+
*/
|
|
14
|
+
previewData?: PreviewData;
|
|
15
|
+
/**
|
|
16
|
+
* A Next.js API endpoint request object.
|
|
17
|
+
*
|
|
18
|
+
* Pass a `req` object when using in a Next.js API endpoint.
|
|
19
|
+
*/
|
|
20
|
+
req?: NextApiRequest;
|
|
21
|
+
} & ClientConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/next",
|
|
3
|
-
"version": "0.1.6-alpha.
|
|
3
|
+
"version": "0.1.6-alpha.1",
|
|
4
4
|
"description": "Helpers to integrate Prismic into Next.js apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"lint": "eslint --ext .js,.ts .",
|
|
38
38
|
"prepare": "npm run build",
|
|
39
39
|
"release": "npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
|
|
40
|
-
"release:alpha": "npm run test && standard-version --release-as
|
|
41
|
-
"release:alpha:dry": "standard-version --release-as
|
|
40
|
+
"release:alpha": "npm run test && standard-version --release-as patch --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
|
|
41
|
+
"release:alpha:dry": "standard-version --release-as patch --prerelease alpha --dry-run",
|
|
42
42
|
"release:dry": "standard-version --dry-run",
|
|
43
43
|
"size": "size-limit",
|
|
44
44
|
"test": "npm run lint && npm run unit && npm run build && npm run size",
|
|
@@ -50,9 +50,6 @@
|
|
|
50
50
|
"@prismicio/helpers": "^2.3.3",
|
|
51
51
|
"@prismicio/react": "^2.5.0",
|
|
52
52
|
"@prismicio/types": "^0.2.3",
|
|
53
|
-
"@rollup/plugin-typescript": "^8.5.0",
|
|
54
|
-
"eslint-plugin-react": "^7.31.7",
|
|
55
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
56
53
|
"imgix-url-builder": "^0.0.3"
|
|
57
54
|
},
|
|
58
55
|
"devDependencies": {
|
|
@@ -65,6 +62,8 @@
|
|
|
65
62
|
"eslint": "^8.23.0",
|
|
66
63
|
"eslint-config-prettier": "^8.5.0",
|
|
67
64
|
"eslint-plugin-prettier": "^4.2.1",
|
|
65
|
+
"eslint-plugin-react": "^7.31.7",
|
|
66
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
68
67
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
69
68
|
"happy-dom": "^6.0.4",
|
|
70
69
|
"next": "^12.1.4",
|
|
@@ -77,6 +76,7 @@
|
|
|
77
76
|
"standard-version": "^9.5.0",
|
|
78
77
|
"typescript": "^4.8.3",
|
|
79
78
|
"vite": "^3.1.1",
|
|
79
|
+
"vite-plugin-sdk": "^0.0.2",
|
|
80
80
|
"vitest": "^0.23.1"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"react": "^17 || ^18"
|
|
86
86
|
},
|
|
87
87
|
"engines": {
|
|
88
|
-
"node": ">=
|
|
88
|
+
"node": ">=14.15.0"
|
|
89
89
|
},
|
|
90
90
|
"publishConfig": {
|
|
91
91
|
"access": "public"
|