@prismicio/svelte 0.0.8-dev.1 → 0.0.9

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 (49) hide show
  1. package/dist/{components/PrismicEmbed.svelte → PrismicEmbed.svelte} +0 -3
  2. package/dist/PrismicImage.svelte +89 -0
  3. package/dist/PrismicImage.svelte.d.ts +300 -0
  4. package/dist/{components/PrismicLink.svelte → PrismicLink.svelte} +6 -5
  5. package/dist/PrismicLink.svelte.d.ts +267 -0
  6. package/dist/{components/PrismicRichText → PrismicRichText}/DefaultComponent.svelte +10 -2
  7. package/dist/{components/PrismicRichText → PrismicRichText}/DefaultComponent.svelte.d.ts +5 -2
  8. package/dist/PrismicRichText/PrismicRichText.svelte +23 -0
  9. package/dist/{components/PrismicRichText → PrismicRichText}/PrismicRichText.svelte.d.ts +4 -1
  10. package/dist/{components/PrismicRichText → PrismicRichText}/Serialize.svelte +5 -2
  11. package/dist/{components/PrismicText.svelte → PrismicText.svelte} +1 -7
  12. package/dist/SliceZone/SliceZone.svelte +29 -0
  13. package/dist/{components → SliceZone}/SliceZone.svelte.d.ts +2 -5
  14. package/dist/{components → SliceZone}/TodoSliceComponent.svelte +8 -5
  15. package/dist/{components → SliceZone}/TodoSliceComponent.svelte.d.ts +0 -1
  16. package/dist/index.d.ts +6 -1
  17. package/dist/index.js +6 -3
  18. package/dist/src/lib/{components/PrismicImage.svelte → PrismicImage.svelte} +21 -7
  19. package/dist/src/lib/{components/PrismicLink.svelte → PrismicLink.svelte} +13 -2
  20. package/dist/src/lib/{components/PrismicRichText → PrismicRichText}/DefaultComponent.svelte +15 -3
  21. package/dist/src/lib/{components/PrismicRichText → PrismicRichText}/PrismicRichText.svelte +8 -7
  22. package/dist/src/lib/{components/PrismicRichText → PrismicRichText}/Serialize.svelte +4 -1
  23. package/dist/src/lib/{components → SliceZone}/SliceZone.svelte +5 -10
  24. package/dist/src/lib/{components → SliceZone}/TodoSliceComponent.svelte +4 -3
  25. package/dist/src/lib/index.ts +6 -9
  26. package/dist/src/routes/+page.server.ts +5 -6
  27. package/dist/src/routes/+page.svelte +4 -3
  28. package/dist/src/routes/slices/RichText.svelte +12 -0
  29. package/package.json +4 -3
  30. package/dist/__PRODUCTION__.d.ts +0 -7
  31. package/dist/__PRODUCTION__.js +0 -11
  32. package/dist/components/PrismicImage.svelte +0 -90
  33. package/dist/components/PrismicImage.svelte.d.ts +0 -71
  34. package/dist/components/PrismicLink.svelte.d.ts +0 -26
  35. package/dist/components/PrismicRichText/PrismicRichText.svelte +0 -49
  36. package/dist/components/SliceZone.svelte +0 -59
  37. package/dist/components/index.d.ts +0 -6
  38. package/dist/components/index.js +0 -6
  39. package/dist/src/lib/__PRODUCTION__.ts +0 -12
  40. package/dist/src/lib/components/index.ts +0 -11
  41. package/dist/src/routes/components/index.js +0 -1
  42. package/dist/src/routes/slices/RichText/index.svelte +0 -9
  43. package/dist/src/routes/slices/index.ts +0 -2
  44. /package/dist/{components/PrismicEmbed.svelte.d.ts → PrismicEmbed.svelte.d.ts} +0 -0
  45. /package/dist/{components/PrismicRichText → PrismicRichText}/Serialize.svelte.d.ts +0 -0
  46. /package/dist/{components/PrismicText.svelte.d.ts → PrismicText.svelte.d.ts} +0 -0
  47. /package/dist/src/lib/{components/PrismicEmbed.svelte → PrismicEmbed.svelte} +0 -0
  48. /package/dist/src/lib/{components/PrismicText.svelte → PrismicText.svelte} +0 -0
  49. /package/dist/src/routes/slices/{CodeSnippet/index.svelte → CodeSnippet.svelte} +0 -0
@@ -30,6 +30,9 @@
30
30
  /**
31
31
  * An object that maps Rich Text blocks to functions.
32
32
  *
33
+ * **Important**: Your components must be wrapped in a function. For example:
34
+ * `{ heading1: () => Heading }`, not: `{ heading1: Heading }`.
35
+ *
33
36
  * @example A serializer that modififes `h1` and `em` elements:
34
37
  *
35
38
  * ```js
@@ -43,23 +46,21 @@
43
46
  * };
44
47
  * ```
45
48
  */
46
- export let richTextSerializer:
49
+ export let components:
47
50
  | RichTextMapSerializer<typeof SvelteComponent, TreeNode>
48
51
  | RichTextFunctionSerializer<typeof SvelteComponent, TreeNode>
49
52
  | undefined = undefined;
50
53
 
51
- const resolvedSerializer =
52
- typeof richTextSerializer === "object"
53
- ? wrapMapSerializer(richTextSerializer)
54
- : richTextSerializer;
54
+ let resolvedSerializer =
55
+ typeof components === "object" ? wrapMapSerializer(components) : components;
55
56
 
56
57
  const nodes = asTree(field).children;
57
58
  </script>
58
59
 
59
- <!--
60
+ <!--
60
61
  @component
61
62
  Component to render a Prismic Rich Text or Title field as HTML.
62
-
63
+
63
64
  @example Rendering a Link field:
64
65
  ```svelte
65
66
  <PrismicRichText field={document.data.example_rich_text} />
@@ -20,7 +20,10 @@
20
20
  this={(serializer &&
21
21
  serializer(node.type, node.node, node.text, node.children, node.key)) ||
22
22
  Default}
23
- {...node}
23
+ type={node.type}
24
+ node={node.node}
25
+ text={node.text}
26
+ key={node.key}
24
27
  {linkResolver}
25
28
  >
26
29
  {#if node.children.length > 0}
@@ -46,7 +46,8 @@
46
46
  | SliceLikeGraphQL<SliceType>;
47
47
 
48
48
  /**
49
- * An array of Prismic Slices, such as the `slices` property from a Prismic document.
49
+ * An array of Prismic Slices, such as the `slices` property from a Prismic
50
+ * document.
50
51
  */
51
52
  export let slices: SliceLike[] = [];
52
53
 
@@ -80,18 +81,12 @@
80
81
  | SvelteComponent
81
82
  | (new (...args: any[]) => SvelteComponent)
82
83
  | undefined = undefined;
83
-
84
- /**
85
- * Whether the app is in development mode. When true, the SliceZone may
86
- * display error messages in the UI.
87
- */
88
- export let dev: boolean = false;
89
84
  </script>
90
85
 
91
- <!--
86
+ <!--
92
87
  @component
93
88
  Component to render an array of Prismic Slices.
94
-
89
+
95
90
  @example Rendering a Rich Text field:
96
91
  ```svelte
97
92
  <SliceZone slices={document.data.slices} components={{
@@ -107,6 +102,6 @@
107
102
  {#if Component}
108
103
  <svelte:component this={Component} {slice} {slices} {context} {index} />
109
104
  {:else}
110
- <TodoSliceComponent {slice} {dev} />
105
+ <TodoSliceComponent {slice} />
111
106
  {/if}
112
107
  {/each}
@@ -1,17 +1,18 @@
1
1
  <script lang="ts">
2
+ import { DEV } from "esm-env";
3
+
2
4
  export let slice: { slice_type: string } | { type: string };
3
- export let dev: boolean = false;
4
5
 
5
6
  const type = "slice_type" in slice ? slice.slice_type : slice.type;
6
7
 
7
- if (dev)
8
+ if (DEV)
8
9
  console.warn(
9
10
  `[SliceZone] Could not find a component for Slice type "${type}"`,
10
11
  slice,
11
12
  );
12
13
  </script>
13
14
 
14
- {#if dev}
15
+ {#if DEV}
15
16
  <section data-slice-zone-todo-component="" data-slice-type={type}>
16
17
  Could not find a component for Slice type &ldquo;{type}&rdquo;
17
18
  </section>
@@ -1,9 +1,6 @@
1
- export {
2
- // Components
3
- PrismicEmbed,
4
- PrismicImage,
5
- PrismicLink,
6
- PrismicText,
7
- PrismicRichText,
8
- SliceZone,
9
- } from "./components";
1
+ export { default as PrismicEmbed } from "./PrismicEmbed.svelte";
2
+ export { default as PrismicImage } from "./PrismicImage.svelte";
3
+ export { default as PrismicLink } from "./PrismicLink.svelte";
4
+ export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.svelte";
5
+ export { default as PrismicText } from "./PrismicText.svelte";
6
+ export { default as SliceZone } from "./SliceZone/SliceZone.svelte";
@@ -1,5 +1,5 @@
1
1
  import * as prismic from "@prismicio/client";
2
- import type { PageDocument } from "../types/PageDocument.type"
2
+ import type { PageDocument } from "../types/PageDocument.type";
3
3
  import type { PageServerLoad } from "./$types";
4
4
 
5
5
  export const load = (async ({ fetch }) => {
@@ -8,13 +8,12 @@ export const load = (async ({ fetch }) => {
8
8
 
9
9
  const pageDocument: PageDocument = await client.getSingle("homepage");
10
10
 
11
- const exampleClient = prismic.createClient("example-prismic-repo", { fetch })
12
- const exampleDocument = exampleClient.getFirst({ page: 11, pageSize: 1})
13
-
11
+ const exampleClient = prismic.createClient("example-prismic-repo", { fetch });
12
+ const exampleDocument = exampleClient.getFirst({ page: 11, pageSize: 1 });
14
13
 
15
14
  return {
16
15
  pageDocument,
17
- exampleDocument
16
+ exampleDocument,
18
17
  };
19
- // eslint-disable-next-line prettier/prettier
18
+ // eslint-disable-next-line prettier/prettier
20
19
  }) satisfies PageServerLoad;
@@ -7,10 +7,11 @@
7
7
  PrismicText,
8
8
  PrismicEmbed,
9
9
  } from "$lib";
10
- import { RichText, CodeSnippet } from "./slices";
11
10
 
12
11
  import type { PageData } from "./$types";
13
- import { page } from "$app/stores";
12
+
13
+ import CodeSnippet from "./slices/CodeSnippet.svelte";
14
+ import RichText from "./slices/RichText.svelte";
14
15
 
15
16
  const components = {
16
17
  rich_text: RichText,
@@ -29,7 +30,7 @@
29
30
  <h2><code>PrismicImage</code></h2>
30
31
  <PrismicImage
31
32
  field={data.exampleDocument.data.example_image}
32
- height="200px"
33
+ height="200"
33
34
  alt=""
34
35
  />
35
36
  <h2><code>PrismicLink</code></h2>
@@ -0,0 +1,12 @@
1
+ <script lang="ts">
2
+ import { PrismicRichText } from "$lib";
3
+ import type { RichTextSlice } from "../../types";
4
+ import Emphasis from "../components/Emphasis.svelte";
5
+
6
+ export let slice: RichTextSlice;
7
+ </script>
8
+
9
+ <PrismicRichText
10
+ field={slice.primary.content}
11
+ components={{ em: () => Emphasis }}
12
+ />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/svelte",
3
- "version": "0.0.8-dev.1",
3
+ "version": "0.0.9",
4
4
  "description": "Svelte plugin, components, and composables to fetch and present Prismic content",
5
5
  "keywords": [
6
6
  "typescript",
@@ -31,7 +31,7 @@
31
31
  "build": "svelte-package -o dist package && shx cp -r src dist/src",
32
32
  "dev": "vite dev",
33
33
  "format": "prettier --write .",
34
- "prepare": "npm run build",
34
+ "prepare": "npm run build && svelte-kit sync",
35
35
  "release": "npm run build && npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
36
36
  "release:dry": "standard-version --dry-run",
37
37
  "release:alpha": "npm run build && npm run test && standard-version --release-as major --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
@@ -58,6 +58,7 @@
58
58
  "@prismicio/mock": "^0.2.0",
59
59
  "@prismicio/types": "^0.2.7",
60
60
  "@rollup/plugin-inject": "^5.0.3",
61
+ "@sveltejs/adapter-auto": "^2.0.0",
61
62
  "@sveltejs/package": "^2.0.0",
62
63
  "@typescript-eslint/eslint-plugin": "^5.53.0",
63
64
  "@typescript-eslint/parser": "^5.53.0",
@@ -81,7 +82,7 @@
81
82
  "vitest": "^0.28.5"
82
83
  },
83
84
  "engines": {
84
- "node": ">=12.7.0"
85
+ "node": ">=16.14.2"
85
86
  },
86
87
  "publishConfig": {
87
88
  "access": "public"
@@ -1,7 +0,0 @@
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,11 +0,0 @@
1
- // We need to polyfill process if it doesn't exist, such as in the browser.
2
- if (typeof process === "undefined") {
3
- globalThis.process = { env: {} };
4
- }
5
- /**
6
- * `true` if in the production environment, `false` otherwise.
7
- *
8
- * This boolean can be used to perform actions only in development environments,
9
- * such as logging.
10
- */
11
- export const __PRODUCTION__ = process.env.NODE_ENV === "production";
@@ -1,90 +0,0 @@
1
- <script>import * as prismicH from "@prismicio/helpers";
2
- import { __PRODUCTION__ } from "../__PRODUCTION__";
3
- export let field;
4
- export let imgixParams = {};
5
- export let widths = undefined;
6
- export let pixelDensities = undefined;
7
- export let width = undefined;
8
- export let height = undefined;
9
- export let alt = undefined;
10
- export let fallbackAlt = undefined;
11
- const castInt = (input) => {
12
- if (typeof input === "number" ||
13
- typeof input === "undefined" ||
14
- input === null) {
15
- return input;
16
- }
17
- else {
18
- const parsed = Number.parseInt(input);
19
- if (Number.isNaN(parsed)) {
20
- return undefined;
21
- }
22
- else {
23
- return parsed;
24
- }
25
- }
26
- };
27
- const ar = field.dimensions && field.dimensions.width / field.dimensions.height;
28
- const castedWidth = castInt(width);
29
- const castedHeight = castInt(height);
30
- let resolvedWidth = castedWidth ?? (field.dimensions && field.dimensions.width);
31
- let resolvedHeight = castedHeight ?? (field.dimensions && field.dimensions.height);
32
- if (ar &&
33
- castedWidth != null &&
34
- (castedHeight == null || typeof castedWidth !== "undefined")) {
35
- resolvedHeight = castedWidth / ar;
36
- }
37
- else if (ar &&
38
- castedHeight != null &&
39
- (castedWidth == null || typeof castedWidth !== "undefined")) {
40
- resolvedWidth = castedHeight * ar;
41
- }
42
- if (!__PRODUCTION__) {
43
- if (widths && pixelDensities) {
44
- console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`);
45
- }
46
- if (typeof alt === "string" && alt !== "") {
47
- console.warn(`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="".`);
48
- }
49
- if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
50
- console.warn(`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="".`);
51
- }
52
- }
53
- </script>
54
-
55
- <!--
56
- @component
57
- Component to render a Prismic Image field as an `img` element with `width`, `height`, `alt`, `src`, and `srcset` attributes.
58
-
59
- @example Rendering an Image field:
60
- ```svelte
61
- <PrismicImage
62
- field={document.data.example_image}
63
- imgixParams={{ sat: -100 }}
64
- />
65
- ```
66
- -->
67
-
68
- {#if prismicH.isFilled.image(field)}
69
- {@const { src, srcset } =
70
- pixelDensities && !widths
71
- ? prismicH.asImagePixelDensitySrcSet(field, {
72
- pixelDensities:
73
- pixelDensities === "defaults" ? undefined : pixelDensities,
74
- ...imgixParams,
75
- })
76
- : prismicH.asImageWidthSrcSet(field, {
77
- widths: widths === "defaults" ? undefined : widths,
78
- ...imgixParams,
79
- })}
80
- <img
81
- {src}
82
- {srcset}
83
- alt={alt ?? field.alt ?? fallbackAlt}
84
- width={width || height ? resolvedWidth : field.dimensions.width}
85
- height={height || (width ? resolvedHeight : field.dimensions.height)}
86
- {...$$restProps}
87
- />
88
- {:else}
89
- <img alt={field.alt || ""} {...$$restProps} />
90
- {/if}
@@ -1,71 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- import * as prismicH from "@prismicio/helpers";
3
- import type * as prismicT from "@prismicio/types";
4
- declare const __propDef: {
5
- props: {
6
- /**
7
- * A Prismic Image field.
8
- */
9
- field: prismicT.ImageField;
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?: Parameters<typeof prismicH.asImageSrc>[1];
16
- /**
17
- * Widths used to build a `srcset` value for the Image field.
18
- *
19
- * If a `widths` prop is not given or `"defaults"` is passed, the following
20
- * widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
21
- *
22
- * If the Image field contains responsive views, each responsive view can be
23
- * used as a width in the resulting `srcset` by passing `"thumbnails"` as
24
- * the `widths` prop.
25
- */
26
- widths?: NonNullable<Parameters<typeof prismicH.asImageWidthSrcSet>[1]>["widths"] | "defaults";
27
- /**
28
- * Pixel densities used to build a `srcset` value for the Image field.
29
- *
30
- * If a `pixelDensities` prop is passed `"defaults"`, the following pixel
31
- * densities will be used: 1, 2, 3.
32
- */
33
- pixelDensities?: NonNullable<Parameters<typeof prismicH.asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
34
- /**
35
- * Declare an image as decorative by providing `alt=""`.
36
- *
37
- * See:
38
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
39
- */
40
- alt?: "" | undefined;
41
- /**
42
- * Declare an image as decorative only if the Image field does not have
43
- * alternative text by providing `fallbackAlt=""`.
44
- *
45
- * See:
46
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
47
- */
48
- fallbackAlt?: "" | undefined;
49
- };
50
- events: {
51
- [evt: string]: CustomEvent<any>;
52
- };
53
- slots: {};
54
- };
55
- export type PrismicImageProps = typeof __propDef.props;
56
- export type PrismicImageEvents = typeof __propDef.events;
57
- export type PrismicImageSlots = typeof __propDef.slots;
58
- /**
59
- * Component to render a Prismic Image field as an `img` element with `width`, `height`, `alt`, `src`, and `srcset` attributes.
60
- *
61
- * @example Rendering an Image field:
62
- * ```svelte
63
- * <PrismicImage
64
- * field={document.data.example_image}
65
- * imgixParams={{ sat: -100 }}
66
- * />
67
- * ```
68
- */
69
- export default class PrismicImage extends SvelteComponentTyped<PrismicImageProps, PrismicImageEvents, PrismicImageSlots> {
70
- }
71
- export {};
@@ -1,26 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: any;
4
- events: {
5
- [evt: string]: CustomEvent<any>;
6
- };
7
- slots: {
8
- default: {};
9
- };
10
- };
11
- export type PrismicLinkProps = typeof __propDef.props;
12
- export type PrismicLinkEvents = typeof __propDef.events;
13
- export type PrismicLinkSlots = typeof __propDef.slots;
14
- /**
15
- * Component to render a Prismic Link, Link to Media, Content Relationship, or whole Document as an `a` tag.
16
- *
17
- * @example Rendering a Link field:
18
- * ```svelte
19
- * <PrismicLink field={document.data.example_link}>
20
- * Example anchor text.
21
- * </PrismicLink>
22
- * ```
23
- */
24
- export default class PrismicLink extends SvelteComponentTyped<PrismicLinkProps, PrismicLinkEvents, PrismicLinkSlots> {
25
- }
26
- export {};
@@ -1,49 +0,0 @@
1
- <script>import { asTree, wrapMapSerializer, } from "@prismicio/richtext";
2
- import Serialize from "./Serialize.svelte";
3
- /**
4
- * The Prismic Rich Text field to render.
5
- */
6
- export let field = [];
7
- /**
8
- * The Link Resolver used to resolve links.
9
- *
10
- * @remarks
11
- * If your app uses Route Resolvers when querying for your Prismic
12
- * repository's content, a Link Resolver does not need to be provided.
13
- * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/route-resolver}
14
- */
15
- export let linkResolver = undefined;
16
- /**
17
- * An object that maps Rich Text blocks to functions.
18
- *
19
- * @example A serializer that modififes `h1` and `em` elements:
20
- *
21
- * ```js
22
- * import Title from "./Title.svelte";
23
- *
24
- * const field = exampleRichText;
25
- *
26
- * const richTextSerializer = {
27
- * h1: () => Title,
28
- * em: ({ children }) => `<mark>${children}</mark>`,
29
- * };
30
- * ```
31
- */
32
- export let richTextSerializer = undefined;
33
- const resolvedSerializer = typeof richTextSerializer === "object"
34
- ? wrapMapSerializer(richTextSerializer)
35
- : richTextSerializer;
36
- const nodes = asTree(field).children;
37
- </script>
38
-
39
- <!--
40
- @component
41
- Component to render a Prismic Rich Text or Title field as HTML.
42
-
43
- @example Rendering a Link field:
44
- ```svelte
45
- <PrismicRichText field={document.data.example_rich_text} />
46
- ```
47
- -->
48
-
49
- <Serialize {nodes} serializer={resolvedSerializer} {linkResolver} />
@@ -1,59 +0,0 @@
1
- <script>import TodoSliceComponent from "./TodoSliceComponent.svelte";
2
- /**
3
- * An array of Prismic Slices, such as the `slices` property from a Prismic document.
4
- */
5
- export let slices = [];
6
- /**
7
- * An object that maps Slice components to their corresponding API IDs
8
- *
9
- * @example An example map:
10
- *
11
- * ```js
12
- * import BlockQuote from "./BlockQuote.svelte";
13
- * import HeroImage from "./HeroImage.svelte";
14
- *
15
- * const components = {
16
- * block_quote: BlockQuote,
17
- * hero_image: HeroImage,
18
- * };
19
- * ```
20
- */
21
- export let components = {};
22
- /**
23
- * Arbitrary data passed to all Slice components as a `context` prop.
24
- */
25
- export let context = {};
26
- /**
27
- * The Svelte component rendered if a component mapping from the `components`
28
- * prop cannot be found.
29
- */
30
- export let defaultComponent = undefined;
31
- /**
32
- * Whether the app is in development mode. When true, the SliceZone may
33
- * display error messages in the UI.
34
- */
35
- export let dev = false;
36
- </script>
37
-
38
- <!--
39
- @component
40
- Component to render an array of Prismic Slices.
41
-
42
- @example Rendering a Rich Text field:
43
- ```svelte
44
- <SliceZone slices={document.data.slices} components={{
45
- block_quote: BlockQuote,
46
- hero_image: HeroImage
47
- }} />
48
- ```
49
- -->
50
-
51
- {#each slices as slice, index}
52
- {@const type = "slice_type" in slice ? slice.slice_type : slice.type}
53
- {@const Component = components[type] || defaultComponent}
54
- {#if Component}
55
- <svelte:component this={Component} {slice} {slices} {context} {index} />
56
- {:else}
57
- <TodoSliceComponent {slice} {dev} />
58
- {/if}
59
- {/each}
@@ -1,6 +0,0 @@
1
- export { default as PrismicEmbed } from "./PrismicEmbed.svelte";
2
- export { default as PrismicImage } from "./PrismicImage.svelte";
3
- export { default as PrismicLink } from "./PrismicLink.svelte";
4
- export { default as PrismicText } from "./PrismicText.svelte";
5
- export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.svelte";
6
- export { default as SliceZone } from "./SliceZone.svelte";
@@ -1,6 +0,0 @@
1
- export { default as PrismicEmbed } from "./PrismicEmbed.svelte";
2
- export { default as PrismicImage } from "./PrismicImage.svelte";
3
- export { default as PrismicLink } from "./PrismicLink.svelte";
4
- export { default as PrismicText } from "./PrismicText.svelte";
5
- export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.svelte";
6
- export { default as SliceZone } from "./SliceZone.svelte";
@@ -1,12 +0,0 @@
1
- // We need to polyfill process if it doesn't exist, such as in the browser.
2
- if (typeof process === "undefined") {
3
- globalThis.process = { env: {} } as typeof process;
4
- }
5
-
6
- /**
7
- * `true` if in the production environment, `false` otherwise.
8
- *
9
- * This boolean can be used to perform actions only in development environments,
10
- * such as logging.
11
- */
12
- export const __PRODUCTION__ = process.env.NODE_ENV === "production";
@@ -1,11 +0,0 @@
1
- export { default as PrismicEmbed } from "./PrismicEmbed.svelte";
2
-
3
- export { default as PrismicImage } from "./PrismicImage.svelte";
4
-
5
- export { default as PrismicLink } from "./PrismicLink.svelte";
6
-
7
- export { default as PrismicText } from "./PrismicText.svelte";
8
-
9
- export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.svelte";
10
-
11
- export { default as SliceZone } from "./SliceZone.svelte";
@@ -1 +0,0 @@
1
- export { default as Em } from "./Emphasis.svelte";
@@ -1,9 +0,0 @@
1
- <script lang="ts">
2
- import type { RichTextSlice } from "./../../../types/RichTextSlice.type";
3
- import PrismicRichText from "$lib/components/PrismicRichText/PrismicRichText.svelte";
4
- import Emphasis from "./../../components/Emphasis.svelte";
5
-
6
- export let slice: RichTextSlice;
7
- </script>
8
-
9
- <PrismicRichText field={slice.primary.content} components={{ em: Emphasis }} />
@@ -1,2 +0,0 @@
1
- export { default as CodeSnippet } from "./CodeSnippet/index.svelte";
2
- export { default as RichText } from "./RichText/index.svelte";