@prismicio/svelte 2.2.1 → 2.2.2-canary.6d1bc0d

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 (50) hide show
  1. package/README.md +6 -0
  2. package/dist/PrismicEmbed.svelte +6 -8
  3. package/dist/PrismicEmbed.svelte.d.ts +1 -3
  4. package/dist/PrismicImage.svelte +46 -68
  5. package/dist/PrismicImage.svelte.d.ts +11 -17
  6. package/dist/PrismicLink.svelte +23 -34
  7. package/dist/PrismicLink.svelte.d.ts +5 -10
  8. package/dist/PrismicRichText/DefaultComponent.svelte +9 -13
  9. package/dist/PrismicRichText/PrismicRichText.svelte +11 -16
  10. package/dist/PrismicRichText/PrismicRichText.svelte.d.ts +2 -6
  11. package/dist/PrismicRichText/Serialize.svelte +11 -19
  12. package/dist/PrismicTable.svelte +26 -41
  13. package/dist/PrismicTable.svelte.d.ts +4 -8
  14. package/dist/PrismicText.svelte +16 -20
  15. package/dist/PrismicText.svelte.d.ts +4 -8
  16. package/dist/SliceSimulator.svelte +12 -12
  17. package/dist/SliceZone/SliceZone.svelte +21 -26
  18. package/dist/SliceZone/SliceZone.svelte.d.ts +12 -16
  19. package/dist/SliceZone/TodoComponent.svelte +7 -7
  20. package/dist/index.d.ts +1 -3
  21. package/dist/kit/PrismicPreview.svelte +32 -48
  22. package/dist/kit/PrismicPreview.svelte.d.ts +5 -9
  23. package/dist/kit/enableAutoPreviews.d.ts +5 -10
  24. package/dist/kit/enableAutoPreviews.js +1 -2
  25. package/dist/kit/redirectToPreviewURL.d.ts +13 -21
  26. package/dist/kit/redirectToPreviewURL.js +10 -11
  27. package/dist/kit/types.d.ts +3 -6
  28. package/dist/lib/devMsg.d.ts +6 -8
  29. package/dist/lib/devMsg.js +6 -8
  30. package/dist/types.d.ts +23 -39
  31. package/package.json +41 -44
  32. package/src/PrismicEmbed.svelte +6 -8
  33. package/src/PrismicImage.svelte +46 -68
  34. package/src/PrismicLink.svelte +23 -34
  35. package/src/PrismicRichText/DefaultComponent.svelte +9 -13
  36. package/src/PrismicRichText/PrismicRichText.svelte +11 -16
  37. package/src/PrismicRichText/Serialize.svelte +11 -19
  38. package/src/PrismicTable.svelte +26 -41
  39. package/src/PrismicText.svelte +16 -20
  40. package/src/SliceSimulator.svelte +12 -12
  41. package/src/SliceZone/SliceZone.svelte +21 -26
  42. package/src/SliceZone/TodoComponent.svelte +7 -7
  43. package/src/index.ts +13 -15
  44. package/src/kit/PrismicPreview.svelte +32 -48
  45. package/src/kit/enableAutoPreviews.ts +14 -19
  46. package/src/kit/index.ts +6 -6
  47. package/src/kit/redirectToPreviewURL.ts +28 -38
  48. package/src/kit/types.ts +7 -10
  49. package/src/lib/devMsg.ts +9 -11
  50. package/src/types.ts +84 -106
@@ -2,17 +2,13 @@ import type { TableField } from "@prismicio/client";
2
2
  import type { Component } from "svelte";
3
3
  import type { RichTextComponents, TableComponents } from "./types";
4
4
  type Props = {
5
- /**
6
- * The Prismic table field to render.
7
- */
5
+ /** The Prismic table field to render. */
8
6
  field: TableField;
9
- /**
10
- * An object that maps a rich text block type to a Svelte component.
11
- */
7
+ /** An object that maps a rich text block type to a Svelte component. */
12
8
  components?: TableComponents & RichTextComponents;
13
9
  /**
14
- * The component rendered when the field is empty. If a fallback is not
15
- * given, `null` will be rendered.
10
+ * The component rendered when the field is empty. If a fallback is not given, `null` will be
11
+ * rendered.
16
12
  */
17
13
  fallback?: Component;
18
14
  };
@@ -1,29 +1,25 @@
1
1
  <script lang="ts">
2
- import type { RichTextField } from "@prismicio/client";
3
- import { asText, isFilled } from "@prismicio/client";
4
- import { DEV } from "esm-env";
2
+ import type { RichTextField } from "@prismicio/client"
3
+ import { asText, isFilled } from "@prismicio/client"
4
+ import { DEV } from "esm-env"
5
5
 
6
- import { devMsg } from "./lib/devMsg";
6
+ import { devMsg } from "./lib/devMsg"
7
7
 
8
8
  type Props = {
9
- /**
10
- * A Rich Text or Title field from Prismic.
11
- */
12
- field: RichTextField;
9
+ /** A Rich Text or Title field from Prismic. */
10
+ field: RichTextField
13
11
 
14
- /**
15
- * The separator used between blocks. Defaults to `\n`.
16
- */
17
- separator?: string | undefined;
12
+ /** The separator used between blocks. Defaults to `\n`. */
13
+ separator?: string | undefined
18
14
 
19
15
  /**
20
- * The string rendered when the field is empty. If a fallback is not given,
21
- * `null` will be rendered.
16
+ * The string rendered when the field is empty. If a fallback is not given, `null` will be
17
+ * rendered.
22
18
  */
23
- fallback?: string | undefined;
24
- };
19
+ fallback?: string | undefined
20
+ }
25
21
 
26
- const { field, separator, fallback, ...restProps }: Props = $props();
22
+ const { field, separator, fallback, ...restProps }: Props = $props()
27
23
 
28
24
  $effect(() => {
29
25
  if (DEV) {
@@ -33,10 +29,10 @@
33
29
  "classname-is-not-a-valid-prop",
34
30
  )}.`,
35
31
  $state.snapshot(field),
36
- );
32
+ )
37
33
  }
38
34
  }
39
- });
35
+ })
40
36
 
41
37
  if (DEV) {
42
38
  if (typeof field === "string") {
@@ -44,7 +40,7 @@
44
40
  `[PrismicText] The "field" prop only accepts a Rich Text or Title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(
45
41
  "prismictext-works-only-with-rich-text-and-title-fields",
46
42
  )}`,
47
- );
43
+ )
48
44
  }
49
45
  }
50
46
  </script>
@@ -1,16 +1,12 @@
1
1
  import type { RichTextField } from "@prismicio/client";
2
2
  type Props = {
3
- /**
4
- * A Rich Text or Title field from Prismic.
5
- */
3
+ /** A Rich Text or Title field from Prismic. */
6
4
  field: RichTextField;
7
- /**
8
- * The separator used between blocks. Defaults to `\n`.
9
- */
5
+ /** The separator used between blocks. Defaults to `\n`. */
10
6
  separator?: string | undefined;
11
7
  /**
12
- * The string rendered when the field is empty. If a fallback is not given,
13
- * `null` will be rendered.
8
+ * The string rendered when the field is empty. If a fallback is not given, `null` will be
9
+ * rendered.
14
10
  */
15
11
  fallback?: string | undefined;
16
12
  };
@@ -9,35 +9,35 @@
9
9
  onClickHandler,
10
10
  simulatorClass,
11
11
  simulatorRootClass,
12
- } from "@prismicio/simulator/kit";
12
+ } from "@prismicio/simulator/kit"
13
13
 
14
- const defaultProps = getDefaultProps();
14
+ const defaultProps = getDefaultProps()
15
15
 
16
- export let zIndex = defaultProps.zIndex;
17
- export let background = defaultProps.background;
16
+ export let zIndex = defaultProps.zIndex
17
+ export let background = defaultProps.background
18
18
 
19
- let slices = getDefaultSlices();
20
- let message = getDefaultMessage();
19
+ let slices = getDefaultSlices()
20
+ let message = getDefaultMessage()
21
21
 
22
22
  if (typeof window !== "undefined") {
23
- const simulatorManager = new SimulatorManager();
23
+ const simulatorManager = new SimulatorManager()
24
24
 
25
25
  simulatorManager.state.on(
26
26
  StateEventType.Slices,
27
27
  (newSlices) => {
28
- slices = newSlices;
28
+ slices = newSlices
29
29
  },
30
30
  "simulator-slices",
31
- );
31
+ )
32
32
  simulatorManager.state.on(
33
33
  StateEventType.Message,
34
34
  (newMessage) => {
35
- message = newMessage;
35
+ message = newMessage
36
36
  },
37
37
  "simulator-message",
38
- );
38
+ )
39
39
 
40
- simulatorManager.init();
40
+ simulatorManager.init()
41
41
  }
42
42
  </script>
43
43
 
@@ -1,54 +1,49 @@
1
1
  <script lang="ts">
2
- import type { Component } from "svelte";
2
+ import type { Component } from "svelte"
3
3
 
4
- import type { SliceComponentProps, SliceZoneLike } from "../types";
5
-
6
- import TodoComponent from "./TodoComponent.svelte";
4
+ import type { SliceComponentProps, SliceZoneLike } from "../types"
5
+ import TodoComponent from "./TodoComponent.svelte"
7
6
 
8
7
  type Props = {
9
- /**
10
- * An array of Prismic Slices, such as the `slices` property from a Prismic
11
- * document.
12
- */
13
- slices?: SliceZoneLike;
8
+ /** An array of Prismic Slices, such as the `slices` property from a Prismic document. */
9
+ slices?: SliceZoneLike
14
10
 
15
11
  /**
16
12
  * An object that maps Slice components to their corresponding API IDs.
17
13
  *
18
- * @example An example map:
14
+ * @example
15
+ * An example map:
19
16
  *
20
- * ```js
21
- * import BlockQuote from "./BlockQuote.svelte";
22
- * import HeroImage from "./HeroImage.svelte";
17
+ * ```js
18
+ * import BlockQuote from "./BlockQuote.svelte";
19
+ * import HeroImage from "./HeroImage.svelte";
23
20
  *
24
- * const components = {
21
+ * const components = {
25
22
  * block_quote: BlockQuote,
26
23
  * hero_image: HeroImage,
27
- * };
28
- * ```
24
+ * };
25
+ * ```
29
26
  */
30
27
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
- components?: Record<string, Component<any>>;
28
+ components?: Record<string, Component<any>>
32
29
 
33
- /**
34
- * Arbitrary data passed to all Slice components as a `context` prop.
35
- */
30
+ /** Arbitrary data passed to all Slice components as a `context` prop. */
36
31
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
- context?: any;
32
+ context?: any
38
33
 
39
34
  /**
40
- * The Svelte component rendered if a component mapping from the
41
- * `components` prop cannot be found.
35
+ * The Svelte component rendered if a component mapping from the `components` prop cannot be
36
+ * found.
42
37
  */
43
- defaultComponent?: Component<SliceComponentProps> | undefined;
44
- };
38
+ defaultComponent?: Component<SliceComponentProps> | undefined
39
+ }
45
40
 
46
41
  const {
47
42
  slices = [],
48
43
  components = {},
49
44
  context = {},
50
45
  defaultComponent = undefined,
51
- }: Props = $props();
46
+ }: Props = $props()
52
47
  </script>
53
48
 
54
49
  <!--
@@ -1,34 +1,30 @@
1
1
  import type { Component } from "svelte";
2
2
  import type { SliceComponentProps, SliceZoneLike } from "../types";
3
3
  type Props = {
4
- /**
5
- * An array of Prismic Slices, such as the `slices` property from a Prismic
6
- * document.
7
- */
4
+ /** An array of Prismic Slices, such as the `slices` property from a Prismic document. */
8
5
  slices?: SliceZoneLike;
9
6
  /**
10
7
  * An object that maps Slice components to their corresponding API IDs.
11
8
  *
12
- * @example An example map:
9
+ * @example
10
+ * An example map:
13
11
  *
14
- * ```js
15
- * import BlockQuote from "./BlockQuote.svelte";
16
- * import HeroImage from "./HeroImage.svelte";
12
+ * ```js
13
+ * import BlockQuote from "./BlockQuote.svelte";
14
+ * import HeroImage from "./HeroImage.svelte";
17
15
  *
18
- * const components = {
16
+ * const components = {
19
17
  * block_quote: BlockQuote,
20
18
  * hero_image: HeroImage,
21
- * };
22
- * ```
19
+ * };
20
+ * ```
23
21
  */
24
22
  components?: Record<string, Component<any>>;
25
- /**
26
- * Arbitrary data passed to all Slice components as a `context` prop.
27
- */
23
+ /** Arbitrary data passed to all Slice components as a `context` prop. */
28
24
  context?: any;
29
25
  /**
30
- * The Svelte component rendered if a component mapping from the
31
- * `components` prop cannot be found.
26
+ * The Svelte component rendered if a component mapping from the `components` prop cannot be
27
+ * found.
32
28
  */
33
29
  defaultComponent?: Component<SliceComponentProps> | undefined;
34
30
  };
@@ -1,22 +1,22 @@
1
1
  <script lang="ts">
2
- import { DEV } from "esm-env";
2
+ import { DEV } from "esm-env"
3
3
 
4
4
  type Props = {
5
- slice: { slice_type: string } | { type: string };
6
- };
5
+ slice: { slice_type: string } | { type: string }
6
+ }
7
7
 
8
- const { slice }: Props = $props();
8
+ const { slice }: Props = $props()
9
9
 
10
- const type = $derived("slice_type" in slice ? slice.slice_type : slice.type);
10
+ const type = $derived("slice_type" in slice ? slice.slice_type : slice.type)
11
11
 
12
12
  $effect(() => {
13
13
  if (DEV) {
14
14
  console.warn(
15
15
  `[SliceZone] Could not find a component for Slice type "${type}"`,
16
16
  $state.snapshot(slice),
17
- );
17
+ )
18
18
  }
19
- });
19
+ })
20
20
  </script>
21
21
 
22
22
  {#if DEV}
package/dist/index.d.ts CHANGED
@@ -7,9 +7,7 @@ export { default as PrismicTable } from "./PrismicTable.svelte";
7
7
  export { default as PrismicText } from "./PrismicText.svelte";
8
8
  export { default as SliceZone } from "./SliceZone/SliceZone.svelte";
9
9
  export { default as SliceSimulator } from "./SliceSimulator.svelte";
10
- /**
11
- * @deprecated Replaced with `RichTextComponents`
12
- */
10
+ /** @deprecated Replaced with `RichTextComponents` */
13
11
  export type SvelteRichTextSerializer = RichTextComponents;
14
12
  export type { RichTextComponents };
15
13
  export type { RichTextComponentProps, SliceComponentProps } from "./types";
@@ -1,62 +1,51 @@
1
1
  <script lang="ts">
2
- import { beforeNavigate, goto, invalidateAll } from "$app/navigation";
3
- import { getToolbarSrc } from "@prismicio/client";
4
- import { onMount } from "svelte";
2
+ import { beforeNavigate, goto, invalidateAll } from "$app/navigation"
3
+ import { getToolbarSrc } from "@prismicio/client"
4
+ import { onMount } from "svelte"
5
5
 
6
6
  type Props = {
7
7
  /**
8
- * The name of your Prismic repository. A Prismic Toolbar will be registered
9
- * using this repository.
8
+ * The name of your Prismic repository. A Prismic Toolbar will be registered using this
9
+ * repository.
10
10
  */
11
- repositoryName: string;
11
+ repositoryName: string
12
12
 
13
- /**
14
- * The route parameter prefixed during preview sessions.
15
- */
16
- routePrefix?: string;
13
+ /** The route parameter prefixed during preview sessions. */
14
+ routePrefix?: string
17
15
 
18
16
  /**
19
- * The name of the preview-specific route parameter prefixed during preview
20
- * sessions.
17
+ * The name of the preview-specific route parameter prefixed during preview sessions.
21
18
  *
22
- * Only set this value if the route parameter's name differs from the
23
- * parameter's value.
19
+ * Only set this value if the route parameter's name differs from the parameter's value.
24
20
  */
25
- routePrefixName?: string;
26
- };
21
+ routePrefixName?: string
22
+ }
27
23
 
28
- const {
29
- repositoryName,
30
- routePrefix = "preview",
31
- routePrefixName = routePrefix,
32
- }: Props = $props();
24
+ const { repositoryName, routePrefix = "preview", routePrefixName = routePrefix }: Props = $props()
33
25
 
34
- const toolbarSrc = $derived(getToolbarSrc(repositoryName));
26
+ const toolbarSrc = $derived(getToolbarSrc(repositoryName))
35
27
 
36
- /**
37
- * Set to `true` when the next `beforeNavigate()` call should not prefix the
38
- * route.
39
- */
40
- let endingPreview = $state(false);
28
+ /** Set to `true` when the next `beforeNavigate()` call should not prefix the route. */
29
+ let endingPreview = $state(false)
41
30
 
42
31
  // Register Prismic toolbar event handlers to refresh data on content updates.
43
32
  onMount(() => {
44
- const controller = new AbortController();
33
+ const controller = new AbortController()
45
34
 
46
35
  window.addEventListener(
47
36
  "prismicPreviewUpdate",
48
37
  (event) => {
49
- event.preventDefault();
50
- invalidateAll();
38
+ event.preventDefault()
39
+ invalidateAll()
51
40
  },
52
41
  { signal: controller.signal },
53
- );
42
+ )
54
43
  window.addEventListener(
55
44
  "prismicPreviewEnd",
56
45
  (event) => {
57
- event.preventDefault();
46
+ event.preventDefault()
58
47
 
59
- endingPreview = true;
48
+ endingPreview = true
60
49
 
61
50
  goto(
62
51
  new URL(
@@ -70,15 +59,15 @@
70
59
  invalidateAll: true,
71
60
  noScroll: true,
72
61
  },
73
- );
62
+ )
74
63
  },
75
64
  { signal: controller.signal },
76
- );
65
+ )
77
66
 
78
67
  return () => {
79
- controller.abort();
80
- };
81
- });
68
+ controller.abort()
69
+ }
70
+ })
82
71
 
83
72
  beforeNavigate((navigation) => {
84
73
  // Prefix links with the preview route parameter if the current
@@ -92,19 +81,14 @@
92
81
  // event, don't prefix the route. The exception is only
93
82
  // valid for one call.
94
83
  if (endingPreview) {
95
- endingPreview = false;
96
- return;
84
+ endingPreview = false
85
+ return
97
86
  }
98
87
 
99
- navigation.cancel();
100
- goto(
101
- new URL(
102
- routePrefix + navigation.to.url.pathname,
103
- navigation.to.url.origin,
104
- ),
105
- );
88
+ navigation.cancel()
89
+ goto(new URL(routePrefix + navigation.to.url.pathname, navigation.to.url.origin))
106
90
  }
107
- });
91
+ })
108
92
  </script>
109
93
 
110
94
  <svelte:head>
@@ -1,19 +1,15 @@
1
1
  type Props = {
2
2
  /**
3
- * The name of your Prismic repository. A Prismic Toolbar will be registered
4
- * using this repository.
3
+ * The name of your Prismic repository. A Prismic Toolbar will be registered using this
4
+ * repository.
5
5
  */
6
6
  repositoryName: string;
7
- /**
8
- * The route parameter prefixed during preview sessions.
9
- */
7
+ /** The route parameter prefixed during preview sessions. */
10
8
  routePrefix?: string;
11
9
  /**
12
- * The name of the preview-specific route parameter prefixed during preview
13
- * sessions.
10
+ * The name of the preview-specific route parameter prefixed during preview sessions.
14
11
  *
15
- * Only set this value if the route parameter's name differs from the
16
- * parameter's value.
12
+ * Only set this value if the route parameter's name differs from the parameter's value.
17
13
  */
18
14
  routePrefixName?: string;
19
15
  };
@@ -1,22 +1,17 @@
1
1
  import * as prismic from "@prismicio/client";
2
2
  import type { Cookies } from "@sveltejs/kit";
3
- /**
4
- * Configuration for `enableAutoPreviews`.
5
- */
3
+ /** Configuration for `enableAutoPreviews`. */
6
4
  export type EnableAutoPreviewsConfig = {
7
- /**
8
- * Prismic client with which automatic previews will be enabled.
9
- */
5
+ /** Prismic client with which automatic previews will be enabled. */
10
6
  client: Pick<prismic.Client, "queryContentFromRef">;
11
7
  /**
12
- * The `cookies` object provided to a route's `load()` function. This
13
- * parameter is required to load previews.
8
+ * The `cookies` object provided to a route's `load()` function. This parameter is required to
9
+ * load previews.
14
10
  */
15
11
  cookies?: Cookies;
16
12
  };
17
13
  /**
18
- * Configures a Prismic client to automatically query draft content during a
19
- * preview session.
14
+ * Configures a Prismic client to automatically query draft content during a preview session.
20
15
  *
21
16
  * @param config - Configuration for the function.
22
17
  */
@@ -1,7 +1,6 @@
1
1
  import * as prismic from "@prismicio/client";
2
2
  /**
3
- * Configures a Prismic client to automatically query draft content during a
4
- * preview session.
3
+ * Configures a Prismic client to automatically query draft content during a preview session.
5
4
  *
6
5
  * @param config - Configuration for the function.
7
6
  */
@@ -1,9 +1,7 @@
1
1
  import * as prismic from "@prismicio/client";
2
2
  import type { Cookies } from "@sveltejs/kit";
3
3
  export type RedirectToPreviewURLConfig = {
4
- /**
5
- * The Prismic client configured for the preview session's repository.
6
- */
4
+ /** The Prismic client configured for the preview session's repository. */
7
5
  client: Pick<prismic.Client, "resolvePreviewURL">;
8
6
  /**
9
7
  * The `request` object from a `+server` file.
@@ -17,33 +15,27 @@ export type RedirectToPreviewURLConfig = {
17
15
  * @see SvelteKit `+server` docs: \<https://kit.svelte.dev/docs/routing#server\>
18
16
  */
19
17
  cookies: Cookies;
20
- /**
21
- * The default redirect URL if a URL cannot be determined for the previewed
22
- * document.
23
- */
18
+ /** The default redirect URL if a URL cannot be determined for the previewed document. */
24
19
  defaultURL?: string;
25
- /**
26
- * The route parameter prefixed during preview sessions.
27
- */
20
+ /** The route parameter prefixed during preview sessions. */
28
21
  routePrefix?: string;
29
22
  };
30
23
  /**
31
- * Redirects a visitor to the URL of a previewed Prismic document from within a
32
- * SvelteKit `+server` file.
24
+ * Redirects a visitor to the URL of a previewed Prismic document from within a SvelteKit `+server`
25
+ * file.
33
26
  *
34
27
  * Return the created `Response` in your `+server` file.
35
28
  *
36
29
  * @example
30
+ * ```typescript
31
+ * import { createClient } from "$lib/prismicio.js"
32
+ * import { redirectToPreviewURL } from "@prismicio/svelte/kit"
37
33
  *
38
- * ```typescript
39
- * import { createClient } from "../lib/prismicio.js";
40
- * import { redirectToPreviewURL } from "@prismicio/svelte/kit";
41
- *
42
- * export async function GET({ fetch, request }) {
43
- * const client = createClient({ fetch });
34
+ * export async function GET({ fetch, request }) {
35
+ * const client = createClient({ fetch })
44
36
  *
45
- * return await redirectToPreviewURL({ client, request });
46
- * }
47
- * ```
37
+ * return await redirectToPreviewURL({ client, request })
38
+ * }
39
+ * ```
48
40
  */
49
41
  export declare const redirectToPreviewURL: (config: RedirectToPreviewURLConfig) => Promise<Response>;
@@ -1,22 +1,21 @@
1
1
  import * as prismic from "@prismicio/client";
2
2
  /**
3
- * Redirects a visitor to the URL of a previewed Prismic document from within a
4
- * SvelteKit `+server` file.
3
+ * Redirects a visitor to the URL of a previewed Prismic document from within a SvelteKit `+server`
4
+ * file.
5
5
  *
6
6
  * Return the created `Response` in your `+server` file.
7
7
  *
8
8
  * @example
9
+ * ```typescript
10
+ * import { createClient } from "$lib/prismicio.js"
11
+ * import { redirectToPreviewURL } from "@prismicio/svelte/kit"
9
12
  *
10
- * ```typescript
11
- * import { createClient } from "../lib/prismicio.js";
12
- * import { redirectToPreviewURL } from "@prismicio/svelte/kit";
13
+ * export async function GET({ fetch, request }) {
14
+ * const client = createClient({ fetch })
13
15
  *
14
- * export async function GET({ fetch, request }) {
15
- * const client = createClient({ fetch });
16
- *
17
- * return await redirectToPreviewURL({ client, request });
18
- * }
19
- * ```
16
+ * return await redirectToPreviewURL({ client, request })
17
+ * }
18
+ * ```
20
19
  */
21
20
  export const redirectToPreviewURL = async (config) => {
22
21
  const previewToken = new URL(config.request.url).searchParams.get("token") ?? undefined;
@@ -1,13 +1,10 @@
1
1
  import type { ClientConfig } from "@prismicio/client";
2
2
  import type { Cookies } from "@sveltejs/kit";
3
- /**
4
- * Configuration for creating a Prismic client with automatic preview support in
5
- * SvelteKit apps.
6
- */
3
+ /** Configuration for creating a Prismic client with automatic preview support in SvelteKit apps. */
7
4
  export type CreateClientConfig = ClientConfig & {
8
5
  /**
9
- * The `cookies` object provided to a route's `load()` function. This
10
- * parameter is required to load previews.
6
+ * The `cookies` object provided to a route's `load()` function. This parameter is required to
7
+ * load previews.
11
8
  */
12
9
  cookies?: Cookies;
13
10
  };
@@ -2,15 +2,13 @@
2
2
  * Returns a `prismic.dev/msg` URL for a given message slug.
3
3
  *
4
4
  * @example
5
+ * ```ts
6
+ * devMsg("missing-param")
7
+ * // => "https://prismic.dev/msg/svelte/v1.2.3/missing-param.md"
8
+ * ```
5
9
  *
6
- * ```ts
7
- * devMsg("missing-param");
8
- * // => "https://prismic.dev/msg/svelte/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
- *
10
+ * @param slug - Slug for the message. This corresponds to a Markdown file in the Git repository's
11
+ * `/messages` directory.
14
12
  * @returns The `prismic.dev/msg` URL for the given slug.
15
13
  */
16
14
  export declare const devMsg: (slug: string) => string;