@prismicio/svelte 0.0.3 → 0.0.5
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/CHANGELOG.md +36 -30
- package/PrismicProvider.svelte +1 -2
- package/README.md +1 -1
- package/components/PrismicEmbed.svelte +8 -4
- package/components/PrismicImage.svelte +9 -14
- package/components/PrismicPreview.svelte +9 -4
- package/components/PrismicText.svelte +1 -1
- package/components/SliceZone.svelte +8 -8
- package/components/TodoSliceComponent.svelte +4 -4
- package/{PrismicProvider.svelte.d.ts → lib/PrismicProvider.svelte.d.ts} +3 -3
- package/{components → lib/components}/PrismicEmbed.svelte.d.ts +3 -3
- package/{components → lib/components}/PrismicImage.svelte.d.ts +4 -4
- package/{components → lib/components}/PrismicLink.svelte.d.ts +3 -3
- package/{components → lib/components}/PrismicPreview.svelte.d.ts +3 -3
- package/{components → lib/components}/PrismicRichText.svelte.d.ts +3 -3
- package/{components → lib/components}/PrismicText.svelte.d.ts +3 -3
- package/{components → lib/components}/SliceZone.svelte.d.ts +4 -4
- package/{components → lib/components}/TodoSliceComponent.svelte.d.ts +3 -3
- package/lib/usePrismic.d.ts +2 -0
- package/package.json +25 -20
- package/src/app.html +2 -2
- package/src/lib/PrismicProvider.svelte +3 -3
- package/src/lib/components/PrismicEmbed.svelte +10 -5
- package/src/lib/components/PrismicImage.svelte +12 -24
- package/src/lib/components/PrismicPreview.svelte +24 -19
- package/src/lib/components/PrismicRichText.svelte +7 -7
- package/src/lib/components/PrismicText.svelte +6 -6
- package/src/lib/components/SliceZone.svelte +55 -50
- package/src/lib/components/TodoSliceComponent.svelte +12 -11
- package/src/lib/usePrismic.ts +1 -1
- package/src/routes/+page.server.ts +15 -0
- package/src/routes/+page.svelte +24 -0
- package/src/routes/slices/CodeSnippet/index.svelte +19 -0
- package/src/routes/slices/RichText/index.svelte +8 -0
- package/src/routes/slices/index.ts +2 -2
- package/src/types/CodeSnippetSlice.type.ts +5 -0
- package/src/types/PageDocument.type.ts +7 -0
- package/src/types/PrismicConfig.type.ts +8 -0
- package/src/types/PrismicContext.type.ts +13 -0
- package/src/types/RichTextSlice.type.ts +7 -0
- package/src/types/Route.type.ts +14 -0
- package/src/types/index.ts +6 -0
- package/types/PrismicContext.type.d.ts +7 -0
- package/usePrismic.js +0 -1
- package/src/lib/types.ts +0 -35
- package/src/routes/index.svelte +0 -26
- package/src/routes/index.ts +0 -15
- package/src/routes/slices/CodeSnippet.svelte +0 -19
- package/src/routes/slices/RichText.svelte +0 -8
- package/types.d.ts +0 -27
- package/types.js +0 -1
- package/usePrismic.d.ts +0 -2
- /package/{components → lib/components}/index.d.ts +0 -0
- /package/{configurePrismic.d.ts → lib/configurePrismic.d.ts} +0 -0
- /package/{index.d.ts → lib/index.d.ts} +0 -0
- /package/{injectionSymbols.d.ts → lib/injectionSymbols.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,59 +2,65 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
### [0.0.
|
|
5
|
+
### [0.0.5](https://github.com/prismicio/prismic-svelte/compare/v0.0.4...v0.0.5) (2023-02-23)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
###
|
|
8
|
+
### Chore
|
|
9
9
|
|
|
10
|
-
*
|
|
10
|
+
* upgrade SvelteKit to 1.0 ([#3](https://github.com/prismicio/prismic-svelte/issues/3)) ([8d5addc](https://github.com/prismicio/prismic-svelte/commit/8d5addcdd669895ccacb666286b57af7825f4869))
|
|
11
11
|
|
|
12
|
+
### [0.0.4](https://github.com/prismicio/prismic-svelte/compare/v0.0.3...v0.0.4) (2022-05-27)
|
|
12
13
|
|
|
13
|
-
###
|
|
14
|
+
### Chore
|
|
15
|
+
|
|
16
|
+
- Update docs link ([e8d14cf](https://github.com/prismicio/prismic-svelte/commit/e8d14cf66ee9c52d624848dbcabe29a531ecae5e))
|
|
17
|
+
|
|
18
|
+
### [0.0.3](https://github.com/prismicio/prismic-svelte/compare/v0.0.2...v0.0.3) (2022-05-17)
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- change dev default value to ([11903bc](https://github.com/prismicio/prismic-svelte/commit/11903bc0e11f86e57bdebee3888c8b7efcffac97))
|
|
23
|
+
|
|
24
|
+
### Documentation
|
|
16
25
|
|
|
26
|
+
- add experimental disclaimer ([3779ec1](https://github.com/prismicio/prismic-svelte/commit/3779ec199cbcbf5d04bacbf2274cf484c1eec0db))
|
|
17
27
|
|
|
18
28
|
### Chore
|
|
19
29
|
|
|
20
|
-
|
|
30
|
+
- **deps:** maintain lock file ([d7ab62f](https://github.com/prismicio/prismic-svelte/commit/d7ab62f28884c2734ef2ae96b6a2f094ef835211))
|
|
21
31
|
|
|
22
32
|
### [0.0.2](https://github.com/prismicio/prismic-svelte/compare/v0.0.1...v0.0.2) (2022-05-13)
|
|
23
33
|
|
|
24
|
-
|
|
25
34
|
### Chore
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
- fix release script ([074d4fb](https://github.com/prismicio/prismic-svelte/commit/074d4fbdd6e3a7fd49b2e7fbe6b8a6b7b315491f))
|
|
37
|
+
- fix release script ([026072a](https://github.com/prismicio/prismic-svelte/commit/026072ac3ff6fe08e161ac15c8776767af70f0d3))
|
|
29
38
|
|
|
30
39
|
### 0.0.1 (2022-05-13)
|
|
31
40
|
|
|
32
|
-
|
|
33
41
|
### Features
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
- Change PrismicProvider prop to only Command line to bootstrap prismic projects. ([e4675d4](https://github.com/prismicio/prismic-svelte/commit/e4675d48d4a2d9fe89c04aa4273948ef2a84d018))
|
|
44
|
+
- Finish creating components; Create Slices for route. ([5b18487](https://github.com/prismicio/prismic-svelte/commit/5b1848736dcf5d75e09556a57756017fc46847f4))
|
|
45
|
+
- Get htmlSerializer from context in PrismicRichText ([36664bc](https://github.com/prismicio/prismic-svelte/commit/36664bc72d7e9eb6cd353c96ae22ed209143a905))
|
|
46
|
+
- Handle missing url ([54b3a75](https://github.com/prismicio/prismic-svelte/commit/54b3a7529eda7b29542483a5b7b0ab33c2b22643))
|
|
47
|
+
- Improve mock data ([782a0f0](https://github.com/prismicio/prismic-svelte/commit/782a0f031c41aeefb2d14220146087fc164b6eae))
|
|
48
|
+
- Merge Lucie's and Sam's link components ([3ea6c7f](https://github.com/prismicio/prismic-svelte/commit/3ea6c7fdb48ad718a62f0cf70662fdb79e6e7d96))
|
|
49
|
+
- Rename to ([cc271cb](https://github.com/prismicio/prismic-svelte/commit/cc271cb285089f3bc6104b771711fe62fb3f5fea))
|
|
50
|
+
- revamp slicezone component ([65c55b8](https://github.com/prismicio/prismic-svelte/commit/65c55b84f7c7eea7e65470f6b5a101c7749d2cde))
|
|
51
|
+
- setup link component ([0545d48](https://github.com/prismicio/prismic-svelte/commit/0545d48fcb0413f40e917d1f4857996d5f402e69))
|
|
52
|
+
- setup prismic provider ([9b9752f](https://github.com/prismicio/prismic-svelte/commit/9b9752fce5f4754bc195e83f44a4bb081e203b95))
|
|
53
|
+
- Setup Prismicimage component ([0033cb5](https://github.com/prismicio/prismic-svelte/commit/0033cb515f2444a5f45040d28a27bf05ac7e0dd0))
|
|
47
54
|
|
|
48
55
|
### Bug Fixes
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
- Add shx so commands work cross platform ([1731f64](https://github.com/prismicio/prismic-svelte/commit/1731f64fa9310fdb93cf15b250320e0939d73f8b))
|
|
52
58
|
|
|
53
59
|
### Chore
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
- Add TODOs, rename plaintext component ([691aab7](https://github.com/prismicio/prismic-svelte/commit/691aab7bc9d47d2bdb47024e30ca90301813c85d))
|
|
62
|
+
- init project ([9afa15a](https://github.com/prismicio/prismic-svelte/commit/9afa15a8a4372de8eb5b16e087433d2a640a93a0))
|
|
63
|
+
- maintain repository ([e3ae492](https://github.com/prismicio/prismic-svelte/commit/e3ae492c0c03e121c8bddf03c96065485a448863))
|
|
64
|
+
- migrate to vitest ([bbae453](https://github.com/prismicio/prismic-svelte/commit/bbae45309262b845dde7149ffad938bcc8aabc66))
|
|
65
|
+
- setup todo components ([d57cf26](https://github.com/prismicio/prismic-svelte/commit/d57cf263f5294d9227a43bb9bb82e9e788dca09e))
|
|
66
|
+
- update template config ([93a1b59](https://github.com/prismicio/prismic-svelte/commit/93a1b5971cf796f6eb9433044defc67eccf56bd2))
|
package/PrismicProvider.svelte
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script>import { setContext } from "svelte";
|
|
2
2
|
import { prismicKey } from "./injectionSymbols";
|
|
3
|
-
import "./types";
|
|
4
3
|
// export let client: PrismicContext["client"] = undefined;
|
|
5
4
|
// export let linkResolver: PrismicContext["linkResolver"] = undefined;
|
|
6
5
|
// export let htmlSerializer: PrismicContext["htmlSerializer"] = undefined;
|
|
@@ -15,7 +14,7 @@ setContext(prismicKey, {
|
|
|
15
14
|
client: prismic.client,
|
|
16
15
|
linkResolver: prismic.linkResolver,
|
|
17
16
|
htmlSerializer: prismic.htmlSerializer,
|
|
18
|
-
slices: prismic.slices
|
|
17
|
+
slices: prismic.slices,
|
|
19
18
|
});
|
|
20
19
|
</script>
|
|
21
20
|
|
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ For more clarity on this project and its structure you can also check out the de
|
|
|
75
75
|
|
|
76
76
|
<!-- TODO: Replace link with a more useful one if available -->
|
|
77
77
|
|
|
78
|
-
[prismic-docs]: https://prismic.io/docs
|
|
78
|
+
[prismic-docs]: https://prismic.io/docs/technical-reference/prismicio-svelte
|
|
79
79
|
[changelog]: ./CHANGELOG.md
|
|
80
80
|
[contributing]: ./CONTRIBUTING.md
|
|
81
81
|
[svelte]: https://svelte.dev
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<script>import * as prismicH from "@prismicio/helpers";
|
|
2
|
+
export let field;
|
|
3
|
+
if (!prismicH.isFilled.embed(field)) {
|
|
4
|
+
console.warn("Invalid prop");
|
|
5
|
+
}
|
|
4
6
|
</script>
|
|
5
7
|
|
|
6
|
-
{
|
|
8
|
+
{#if prismicH.isFilled.embed(field)}
|
|
9
|
+
{@html field.html}
|
|
10
|
+
{/if}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
<script>import "@prismicio/
|
|
1
|
+
<script>import * as prismicH from "@prismicio/helpers";
|
|
2
2
|
export let field;
|
|
3
3
|
let className;
|
|
4
4
|
// creates a `class` property, even
|
|
5
5
|
// though it is a reserved word
|
|
6
6
|
export { className as class };
|
|
7
|
-
const usePrismicImage = (field) => {
|
|
8
|
-
field.url;
|
|
9
|
-
return {
|
|
10
|
-
url: field.url || "",
|
|
11
|
-
alt: field.alt || "",
|
|
12
|
-
width: field.dimensions?.width || undefined,
|
|
13
|
-
height: field.dimensions?.height || undefined,
|
|
14
|
-
copyright: field.copyright || undefined,
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
const image = usePrismicImage(field);
|
|
18
7
|
</script>
|
|
19
8
|
|
|
20
|
-
{#if field
|
|
21
|
-
|
|
9
|
+
{#if prismicH.isFilled.image(field)}
|
|
10
|
+
{@const { alt, dimensions } = field}
|
|
11
|
+
{@const { width, height } = dimensions}
|
|
12
|
+
{@const { src, srcset } = prismicH.asImageWidthSrcSet(field)}
|
|
13
|
+
|
|
14
|
+
<img {src} {srcset} {alt} {width} {height} class={className} />
|
|
15
|
+
{:else}
|
|
16
|
+
<img alt={field.alt || ""} class={className} />
|
|
22
17
|
{/if}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
import { goto } from
|
|
1
|
+
<script>import * as prismic from "@prismicio/client";
|
|
2
|
+
import { goto } from "$app/navigation";
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
export let linkResolver;
|
|
5
5
|
export let defaultURL;
|
|
@@ -9,7 +9,12 @@ onMount(async () => {
|
|
|
9
9
|
const previewToken = urlParams.get("token");
|
|
10
10
|
const documentID = urlParams.get("documentId");
|
|
11
11
|
if (documentID && previewToken) {
|
|
12
|
-
const redirect = await client.resolvePreviewURL({
|
|
12
|
+
const redirect = await client.resolvePreviewURL({
|
|
13
|
+
documentID,
|
|
14
|
+
defaultURL,
|
|
15
|
+
previewToken,
|
|
16
|
+
linkResolver,
|
|
17
|
+
});
|
|
13
18
|
await goto(redirect);
|
|
14
19
|
return;
|
|
15
20
|
}
|
|
@@ -18,4 +23,4 @@ onMount(async () => {
|
|
|
18
23
|
});
|
|
19
24
|
</script>
|
|
20
25
|
|
|
21
|
-
<slot
|
|
26
|
+
<slot />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import TodoSliceComponent from
|
|
1
|
+
<script>import TodoSliceComponent from "./TodoSliceComponent.svelte";
|
|
2
2
|
export let slices = [];
|
|
3
3
|
export let components = {};
|
|
4
4
|
export let context = {};
|
|
@@ -7,11 +7,11 @@ export let dev = false;
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
{#each slices as slice, index}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
{@const type = "slice_type" in slice ? slice.slice_type : slice.type}
|
|
11
|
+
{@const Component = components[type] || defaultComponent}
|
|
12
|
+
{#if Component}
|
|
13
|
+
<svelte:component this={Component} {slice} {slices} {context} {index} />
|
|
14
|
+
{:else}
|
|
15
|
+
<TodoSliceComponent {slice} {dev} />
|
|
16
|
+
{/if}
|
|
17
17
|
{/each}
|
|
@@ -6,7 +6,7 @@ if (dev)
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
{#if dev}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{/if}
|
|
9
|
+
<section data-slice-zone-todo-component="" data-slice-type={type}>
|
|
10
|
+
Could not find a component for Slice type “{type}”
|
|
11
|
+
</section>
|
|
12
|
+
{/if}
|
|
@@ -16,9 +16,9 @@ declare const __propDef: {
|
|
|
16
16
|
default: {};
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
19
|
+
export type PrismicProviderProps = typeof __propDef.props;
|
|
20
|
+
export type PrismicProviderEvents = typeof __propDef.events;
|
|
21
|
+
export type PrismicProviderSlots = typeof __propDef.slots;
|
|
22
22
|
export default class PrismicProvider extends SvelteComponentTyped<PrismicProviderProps, PrismicProviderEvents, PrismicProviderSlots> {
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -9,9 +9,9 @@ declare const __propDef: {
|
|
|
9
9
|
};
|
|
10
10
|
slots: {};
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export type PrismicEmbedProps = typeof __propDef.props;
|
|
13
|
+
export type PrismicEmbedEvents = typeof __propDef.events;
|
|
14
|
+
export type PrismicEmbedSlots = typeof __propDef.slots;
|
|
15
15
|
export default class PrismicEmbed extends SvelteComponentTyped<PrismicEmbedProps, PrismicEmbedEvents, PrismicEmbedSlots> {
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import * as prismicT from "@prismicio/types";
|
|
2
|
+
import type * as prismicT from "@prismicio/types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
field: prismicT.ImageField;
|
|
@@ -10,9 +10,9 @@ declare const __propDef: {
|
|
|
10
10
|
};
|
|
11
11
|
slots: {};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
13
|
+
export type PrismicImageProps = typeof __propDef.props;
|
|
14
|
+
export type PrismicImageEvents = typeof __propDef.events;
|
|
15
|
+
export type PrismicImageSlots = typeof __propDef.slots;
|
|
16
16
|
export default class PrismicImage extends SvelteComponentTyped<PrismicImageProps, PrismicImageEvents, PrismicImageSlots> {
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -21,9 +21,9 @@ declare const __propDef: {
|
|
|
21
21
|
default: {};
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
24
|
+
export type PrismicLinkProps = typeof __propDef.props;
|
|
25
|
+
export type PrismicLinkEvents = typeof __propDef.events;
|
|
26
|
+
export type PrismicLinkSlots = typeof __propDef.slots;
|
|
27
27
|
export default class PrismicLink extends SvelteComponentTyped<PrismicLinkProps, PrismicLinkEvents, PrismicLinkSlots> {
|
|
28
28
|
}
|
|
29
29
|
export {};
|
|
@@ -12,9 +12,9 @@ declare const __propDef: {
|
|
|
12
12
|
default: {};
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
15
|
+
export type PrismicPreviewProps = typeof __propDef.props;
|
|
16
|
+
export type PrismicPreviewEvents = typeof __propDef.events;
|
|
17
|
+
export type PrismicPreviewSlots = typeof __propDef.slots;
|
|
18
18
|
export default class PrismicPreview extends SvelteComponentTyped<PrismicPreviewProps, PrismicPreviewEvents, PrismicPreviewSlots> {
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
@@ -12,9 +12,9 @@ declare const __propDef: {
|
|
|
12
12
|
};
|
|
13
13
|
slots: {};
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
15
|
+
export type PrismicRichTextProps = typeof __propDef.props;
|
|
16
|
+
export type PrismicRichTextEvents = typeof __propDef.events;
|
|
17
|
+
export type PrismicRichTextSlots = typeof __propDef.slots;
|
|
18
18
|
export default class PrismicRichText extends SvelteComponentTyped<PrismicRichTextProps, PrismicRichTextEvents, PrismicRichTextSlots> {
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
@@ -11,9 +11,9 @@ declare const __propDef: {
|
|
|
11
11
|
};
|
|
12
12
|
slots: {};
|
|
13
13
|
};
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
14
|
+
export type PrismicTextProps = typeof __propDef.props;
|
|
15
|
+
export type PrismicTextEvents = typeof __propDef.events;
|
|
16
|
+
export type PrismicTextSlots = typeof __propDef.slots;
|
|
17
17
|
export default class PrismicText extends SvelteComponentTyped<PrismicTextProps, PrismicTextEvents, PrismicTextSlots> {
|
|
18
18
|
}
|
|
19
19
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { SvelteComponent } from
|
|
2
|
+
import type { SvelteComponent } from "svelte";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
slices?: ({
|
|
@@ -17,9 +17,9 @@ declare const __propDef: {
|
|
|
17
17
|
};
|
|
18
18
|
slots: {};
|
|
19
19
|
};
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
20
|
+
export type SliceZoneProps = typeof __propDef.props;
|
|
21
|
+
export type SliceZoneEvents = typeof __propDef.events;
|
|
22
|
+
export type SliceZoneSlots = typeof __propDef.slots;
|
|
23
23
|
export default class SliceZone extends SvelteComponentTyped<SliceZoneProps, SliceZoneEvents, SliceZoneSlots> {
|
|
24
24
|
}
|
|
25
25
|
export {};
|
|
@@ -13,9 +13,9 @@ declare const __propDef: {
|
|
|
13
13
|
};
|
|
14
14
|
slots: {};
|
|
15
15
|
};
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
16
|
+
export type TodoSliceComponentProps = typeof __propDef.props;
|
|
17
|
+
export type TodoSliceComponentEvents = typeof __propDef.events;
|
|
18
|
+
export type TodoSliceComponentSlots = typeof __propDef.slots;
|
|
19
19
|
export default class TodoSliceComponent extends SvelteComponentTyped<TodoSliceComponentProps, TodoSliceComponentEvents, TodoSliceComponentSlots> {
|
|
20
20
|
}
|
|
21
21
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Svelte plugin, components, and composables to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"./components": "./components/index.js",
|
|
29
29
|
"./configurePrismic": "./configurePrismic.js",
|
|
30
30
|
"./injectionSymbols": "./injectionSymbols.js",
|
|
31
|
-
"./types": "./types.js",
|
|
32
31
|
"./usePrismic": "./usePrismic.js"
|
|
33
32
|
},
|
|
34
33
|
"main": "index.js",
|
|
@@ -36,38 +35,44 @@
|
|
|
36
35
|
"types": "index.d.ts",
|
|
37
36
|
"svelte": "./index.js",
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"@prismicio/client": "^6.
|
|
40
|
-
"@prismicio/helpers": "^2.3.
|
|
38
|
+
"@prismicio/client": "^6.7.3",
|
|
39
|
+
"@prismicio/helpers": "^2.3.9",
|
|
40
|
+
"@sveltejs/kit": "^1.8.3",
|
|
41
|
+
"svelte": "^3.55.1"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@prismicio/mock": "0.0
|
|
44
|
-
"@prismicio/types": "^0.
|
|
45
|
-
"@rollup/plugin-inject": "^
|
|
46
|
-
"@sveltejs/
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
48
|
-
"@typescript-eslint/parser": "^5.
|
|
49
|
-
"c8": "^
|
|
44
|
+
"@prismicio/mock": "^0.2.0",
|
|
45
|
+
"@prismicio/types": "^0.2.7",
|
|
46
|
+
"@rollup/plugin-inject": "^5.0.3",
|
|
47
|
+
"@sveltejs/package": "^1.0.2",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.53.0",
|
|
49
|
+
"@typescript-eslint/parser": "^5.53.0",
|
|
50
|
+
"@vitest/coverage-c8": "^0.28.5",
|
|
51
|
+
"c8": "^7.13.0",
|
|
50
52
|
"eslint": "^8.15.0",
|
|
51
53
|
"eslint-config-prettier": "^8.5.0",
|
|
52
|
-
"eslint-plugin-prettier": "^4.
|
|
54
|
+
"eslint-plugin-prettier": "^4.2.0",
|
|
53
55
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
54
56
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
55
|
-
"prettier": "^2.
|
|
57
|
+
"prettier": "^2.8.4",
|
|
56
58
|
"prettier-plugin-jsdoc": "^0.3.38",
|
|
59
|
+
"prettier-plugin-svelte": "^2.9.0",
|
|
57
60
|
"shx": "^0.3.4",
|
|
58
61
|
"standard-version": "^9.3.2",
|
|
59
|
-
"svelte": "^3.
|
|
60
|
-
"svelte-
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"vitest": "^0.12.4"
|
|
62
|
+
"svelte-check": "^3.0.3",
|
|
63
|
+
"svelte-preprocess": "^5.0.1",
|
|
64
|
+
"svelte2tsx": "^0.6.1",
|
|
65
|
+
"tslib": "^2.5.0",
|
|
66
|
+
"typescript": "^4.9.5",
|
|
67
|
+
"vitest": "^0.28.5"
|
|
66
68
|
},
|
|
67
69
|
"engines": {
|
|
68
70
|
"node": ">=12.7.0"
|
|
69
71
|
},
|
|
70
72
|
"publishConfig": {
|
|
71
73
|
"access": "public"
|
|
74
|
+
},
|
|
75
|
+
"optionalDependencies": {
|
|
76
|
+
"@esbuild/android-arm": "^0.17.10"
|
|
72
77
|
}
|
|
73
78
|
}
|
package/src/app.html
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<link rel="icon" href="/favicon.png" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
%
|
|
7
|
+
%sveltekit.head%
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
|
-
<div id="svelte">%
|
|
10
|
+
<div id="svelte">%sveltekit.body%</div>
|
|
11
11
|
</body>
|
|
12
12
|
</html>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { setContext } from "svelte";
|
|
3
3
|
|
|
4
4
|
import { prismicKey } from "./injectionSymbols";
|
|
5
|
-
import { PrismicContext } from "
|
|
5
|
+
import type { PrismicContext } from "../types/PrismicContext.type";
|
|
6
6
|
|
|
7
7
|
// export let client: PrismicContext["client"] = undefined;
|
|
8
8
|
// export let linkResolver: PrismicContext["linkResolver"] = undefined;
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
prismic: undefined,
|
|
14
14
|
htmlSerializer: undefined,
|
|
15
15
|
slices: undefined,
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
|
|
18
18
|
setContext<PrismicContext>(prismicKey, {
|
|
19
19
|
client: prismic.client,
|
|
20
20
|
linkResolver: prismic.linkResolver,
|
|
21
21
|
htmlSerializer: prismic.htmlSerializer,
|
|
22
|
-
slices: prismic.slices
|
|
22
|
+
slices: prismic.slices,
|
|
23
23
|
});
|
|
24
24
|
</script>
|
|
25
25
|
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
<!-- TODO: Why are embeds 200px wide? -->
|
|
2
|
-
|
|
3
1
|
<script lang="ts">
|
|
4
|
-
|
|
2
|
+
import * as prismicH from "@prismicio/helpers";
|
|
3
|
+
import type * as prismicT from "@prismicio/types";
|
|
4
|
+
|
|
5
|
+
export let field: prismicT.EmbedField;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
if (!prismicH.isFilled.embed(field)) {
|
|
8
|
+
console.warn("Invalid prop");
|
|
9
|
+
}
|
|
7
10
|
</script>
|
|
8
11
|
|
|
9
|
-
{
|
|
12
|
+
{#if prismicH.isFilled.embed(field)}
|
|
13
|
+
{@html field.html}
|
|
14
|
+
{/if}
|
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import * as
|
|
2
|
+
import * as prismicH from "@prismicio/helpers";
|
|
3
|
+
import type * as prismicT from "@prismicio/types";
|
|
4
|
+
|
|
3
5
|
export let field: prismicT.ImageField;
|
|
6
|
+
|
|
4
7
|
let className: string;
|
|
5
8
|
|
|
6
9
|
// creates a `class` property, even
|
|
7
10
|
// though it is a reserved word
|
|
8
11
|
export { className as class };
|
|
9
|
-
|
|
10
|
-
const usePrismicImage = (
|
|
11
|
-
field: prismicT.ImageField,
|
|
12
|
-
): {
|
|
13
|
-
url: string;
|
|
14
|
-
width?: number;
|
|
15
|
-
height?: number;
|
|
16
|
-
alt?: string;
|
|
17
|
-
copyright: string | undefined;
|
|
18
|
-
} => {
|
|
19
|
-
field.url;
|
|
20
|
-
return {
|
|
21
|
-
url: field.url || "",
|
|
22
|
-
alt: field.alt || "",
|
|
23
|
-
width: field.dimensions?.width || undefined,
|
|
24
|
-
height: field.dimensions?.height || undefined,
|
|
25
|
-
copyright: field.copyright || undefined,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const image = usePrismicImage(field);
|
|
30
12
|
</script>
|
|
31
13
|
|
|
32
|
-
{#if field
|
|
33
|
-
|
|
14
|
+
{#if prismicH.isFilled.image(field)}
|
|
15
|
+
{@const { alt, dimensions } = field}
|
|
16
|
+
{@const { width, height } = dimensions}
|
|
17
|
+
{@const { src, srcset } = prismicH.asImageWidthSrcSet(field)}
|
|
18
|
+
|
|
19
|
+
<img {src} {srcset} {alt} {width} {height} class={className} />
|
|
20
|
+
{:else}
|
|
21
|
+
<img alt={field.alt || ""} class={className} />
|
|
34
22
|
{/if}
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import * as prismic from "@prismicio/client";
|
|
3
|
+
import { goto } from "$app/navigation";
|
|
4
|
+
import { onMount } from "svelte";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export let linkResolver: any;
|
|
7
|
+
export let defaultURL: string;
|
|
8
|
+
export let client: any;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
onMount(async () => {
|
|
11
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
12
|
+
const previewToken = urlParams.get("token");
|
|
13
|
+
const documentID = urlParams.get("documentId");
|
|
14
|
+
if (documentID && previewToken) {
|
|
15
|
+
const redirect = await client.resolvePreviewURL({
|
|
16
|
+
documentID,
|
|
17
|
+
defaultURL,
|
|
18
|
+
previewToken,
|
|
19
|
+
linkResolver,
|
|
20
|
+
});
|
|
21
|
+
await goto(redirect);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
console.log("Could not resolve preview URL.");
|
|
25
|
+
// TODO: Handle else
|
|
26
|
+
});
|
|
22
27
|
</script>
|
|
23
28
|
|
|
24
|
-
<slot
|
|
29
|
+
<slot />
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import * as prismicH from "@prismicio/helpers";
|
|
3
|
+
import { usePrismic } from "./..";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import type { RichTextField as RichTextFieldType } from "@prismicio/types";
|
|
6
|
+
import type { TitleField as TitleFieldType } from "@prismicio/types";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
let { htmlSerializer, linkResolver } = usePrismic();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export let field: TitleFieldType | RichTextFieldType;
|
|
11
|
+
export { htmlSerializer, linkResolver };
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
{@html prismicH.asHTML(field, linkResolver, htmlSerializer)}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
import * as prismicH from "@prismicio/helpers";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import type { RichTextField as RichTextFieldType } from "@prismicio/types";
|
|
5
|
+
import type { TitleField as TitleFieldType } from "@prismicio/types";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export let field: TitleFieldType | RichTextFieldType;
|
|
8
|
+
export let separator: string;
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<!-- TODO: Separator not working for newlines `\n\n` -->
|
|
12
|
-
{@html prismicH.asText(field, separator)}
|
|
12
|
+
{@html prismicH.asText(field, separator)}
|
|
@@ -1,61 +1,66 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type * as prismicT from "@prismicio/types"
|
|
5
|
-
import type { SvelteComponent } from 'svelte';
|
|
2
|
+
import TodoSliceComponent from "./TodoSliceComponent.svelte";
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
import type * as prismicT from "@prismicio/types";
|
|
5
|
+
import type { SvelteComponent } from "svelte";
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
14
|
-
* `@prismicio/types` for a full interface.
|
|
15
|
-
*
|
|
16
|
-
* @typeParam SliceType - Type name of the Slice.
|
|
17
|
-
*/
|
|
18
|
-
type SliceLikeRestV2<SliceType extends string = string> = {
|
|
19
|
-
slice_type: prismicT.Slice<SliceType>["slice_type"];
|
|
20
|
-
};
|
|
7
|
+
type SliceComponents = Record<
|
|
8
|
+
string,
|
|
9
|
+
SvelteComponent | (new (...args: any[]) => SvelteComponent)
|
|
10
|
+
>;
|
|
21
11
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The minimum required properties to represent a Prismic Slice from the
|
|
14
|
+
* Prismic Rest API V2 for the `<SliceZone>` component.
|
|
15
|
+
*
|
|
16
|
+
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
17
|
+
* `@prismicio/types` for a full interface.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam SliceType - Type name of the Slice.
|
|
20
|
+
*/
|
|
21
|
+
type SliceLikeRestV2<SliceType extends string = string> = {
|
|
22
|
+
slice_type: prismicT.Slice<SliceType>["slice_type"];
|
|
23
|
+
};
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
type SliceLike<SliceType extends string = string> =
|
|
42
|
-
| SliceLikeRestV2<SliceType>
|
|
43
|
-
| SliceLikeGraphQL<SliceType>;
|
|
25
|
+
/**
|
|
26
|
+
* The minimum required properties to represent a Prismic Slice from the
|
|
27
|
+
* Prismic GraphQL API for the `<SliceZone>` component.
|
|
28
|
+
*
|
|
29
|
+
* @typeParam SliceType - Type name of the Slice.
|
|
30
|
+
*/
|
|
31
|
+
type SliceLikeGraphQL<SliceType extends string = string> = {
|
|
32
|
+
type: prismicT.Slice<SliceType>["slice_type"];
|
|
33
|
+
};
|
|
44
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The minimum required properties to represent a Prismic Slice for the
|
|
37
|
+
* `<SliceZone>` component.
|
|
38
|
+
*
|
|
39
|
+
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
40
|
+
* `@prismicio/types` for a full interface.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam SliceType - Type name of the Slice.
|
|
43
|
+
*/
|
|
44
|
+
type SliceLike<SliceType extends string = string> =
|
|
45
|
+
| SliceLikeRestV2<SliceType>
|
|
46
|
+
| SliceLikeGraphQL<SliceType>;
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
export let slices: SliceLike[] = [];
|
|
49
|
+
export let components: SliceComponents = {};
|
|
50
|
+
export let context: any = {};
|
|
51
|
+
export let defaultComponent:
|
|
52
|
+
| SvelteComponent
|
|
53
|
+
| (new (...args: any[]) => SvelteComponent)
|
|
54
|
+
| undefined = undefined;
|
|
55
|
+
export let dev: boolean = false;
|
|
51
56
|
</script>
|
|
52
57
|
|
|
53
58
|
{#each slices as slice, index}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
{@const type = "slice_type" in slice ? slice.slice_type : slice.type}
|
|
60
|
+
{@const Component = components[type] || defaultComponent}
|
|
61
|
+
{#if Component}
|
|
62
|
+
<svelte:component this={Component} {slice} {slices} {context} {index} />
|
|
63
|
+
{:else}
|
|
64
|
+
<TodoSliceComponent {slice} {dev} />
|
|
65
|
+
{/if}
|
|
61
66
|
{/each}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export let slice: { slice_type: string } | { type: string };
|
|
3
|
+
export let dev: boolean = false;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const type = "slice_type" in slice ? slice.slice_type : slice.type;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
if (dev)
|
|
8
|
+
console.warn(
|
|
9
|
+
`[SliceZone] Could not find a component for Slice type "${type}"`,
|
|
10
|
+
slice,
|
|
11
|
+
);
|
|
11
12
|
</script>
|
|
12
13
|
|
|
13
14
|
{#if dev}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{/if}
|
|
15
|
+
<section data-slice-zone-todo-component="" data-slice-type={type}>
|
|
16
|
+
Could not find a component for Slice type “{type}”
|
|
17
|
+
</section>
|
|
18
|
+
{/if}
|
package/src/lib/usePrismic.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hasContext, getContext } from "svelte";
|
|
2
2
|
|
|
3
3
|
import { prismicKey } from "./injectionSymbols";
|
|
4
|
-
import { PrismicContext } from "
|
|
4
|
+
import type { PrismicContext } from "../types/PrismicContext.type";
|
|
5
5
|
|
|
6
6
|
export const usePrismic = (): PrismicContext => {
|
|
7
7
|
if (hasContext(prismicKey)) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as prismic from "@prismicio/client";
|
|
2
|
+
import type { PageDocument } from "../types/PageDocument.type"
|
|
3
|
+
import type { PageServerLoad } from "./$types";
|
|
4
|
+
|
|
5
|
+
export const load = (async ({ fetch }) => {
|
|
6
|
+
const endpoint = prismic.getEndpoint("svelte-package-dev");
|
|
7
|
+
const client = prismic.createClient(endpoint, { fetch });
|
|
8
|
+
|
|
9
|
+
const document: PageDocument = await client.getSingle("homepage");
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
document,
|
|
13
|
+
};
|
|
14
|
+
// eslint-disable-next-line prettier/prettier
|
|
15
|
+
}) satisfies PageServerLoad;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { SliceZone } from "$lib";
|
|
3
|
+
import { RichText, CodeSnippet } from "src/routes/slices";
|
|
4
|
+
import type { PageData } from "./$types";
|
|
5
|
+
|
|
6
|
+
const components = {
|
|
7
|
+
rich_text: RichText,
|
|
8
|
+
code_snippet: CodeSnippet,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export let data: PageData;
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<main>
|
|
15
|
+
<h1>Welcome to SvelteKit</h1>
|
|
16
|
+
<SliceZone slices={data.document.data.body} {components} />
|
|
17
|
+
</main>
|
|
18
|
+
|
|
19
|
+
<style>
|
|
20
|
+
main {
|
|
21
|
+
max-width: min(90%, 800px);
|
|
22
|
+
margin: auto;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as prismicH from "@prismicio/helpers";
|
|
3
|
+
import type { CodeSnippetSlice } from "../../../types/CodeSnippetSlice.type";
|
|
4
|
+
|
|
5
|
+
export let slice: CodeSnippetSlice;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<pre>
|
|
9
|
+
{@html prismicH.asHTML(slice.primary.content)}
|
|
10
|
+
</pre>
|
|
11
|
+
|
|
12
|
+
<style>
|
|
13
|
+
pre {
|
|
14
|
+
background: #222;
|
|
15
|
+
color: white;
|
|
16
|
+
padding: 10px;
|
|
17
|
+
border-radius: 10px;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as CodeSnippet } from "./CodeSnippet.svelte";
|
|
2
|
-
export { default as RichText } from "./RichText.svelte";
|
|
1
|
+
export { default as CodeSnippet } from "./CodeSnippet/index.svelte";
|
|
2
|
+
export { default as RichText } from "./RichText/index.svelte";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as prismicT from "@prismicio/types";
|
|
2
|
+
import type { CodeSnippetSlice } from "./CodeSnippetSlice.type";
|
|
3
|
+
import type { RichTextSlice } from "./RichTextSlice.type";
|
|
4
|
+
|
|
5
|
+
export type PageDocument = prismicT.PrismicDocument<{
|
|
6
|
+
body: prismicT.SliceZone<CodeSnippetSlice | RichTextSlice>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Client } from "@prismicio/client";
|
|
2
|
+
import type {
|
|
3
|
+
LinkResolverFunction,
|
|
4
|
+
HTMLFunctionSerializer,
|
|
5
|
+
HTMLMapSerializer,
|
|
6
|
+
} from "@prismicio/helpers";
|
|
7
|
+
// import type * as prismicH from "@prismicio/helpers";
|
|
8
|
+
|
|
9
|
+
export type PrismicContext = {
|
|
10
|
+
client?: Client;
|
|
11
|
+
linkResolver?: LinkResolverFunction;
|
|
12
|
+
htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Route {
|
|
2
|
+
/**
|
|
3
|
+
* The Custom Type of the document.
|
|
4
|
+
*/
|
|
5
|
+
type: string;
|
|
6
|
+
/**
|
|
7
|
+
* The resolved path of the document with optional placeholders.
|
|
8
|
+
*/
|
|
9
|
+
path: string;
|
|
10
|
+
/**
|
|
11
|
+
* An object that lists the API IDs of the Content Relationships in the route.
|
|
12
|
+
*/
|
|
13
|
+
resolvers: Record<string, string>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { CodeSnippetSlice } from "./CodeSnippetSlice.type";
|
|
2
|
+
export type { PageData } from "./PageDocument.type";
|
|
3
|
+
export type { PrismicConfig } from "./PrismicConfig.type";
|
|
4
|
+
export type { PrismicContext } from "./PrismicContext.type";
|
|
5
|
+
export type { RichTextSlice } from "./RichTextSlice.type";
|
|
6
|
+
export type { Route } from "./Route.type";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Client } from "@prismicio/client";
|
|
2
|
+
import type { LinkResolverFunction, HTMLFunctionSerializer, HTMLMapSerializer } from "@prismicio/helpers";
|
|
3
|
+
export type PrismicContext = {
|
|
4
|
+
client?: Client;
|
|
5
|
+
linkResolver?: LinkResolverFunction;
|
|
6
|
+
htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
|
|
7
|
+
};
|
package/usePrismic.js
CHANGED
package/src/lib/types.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Client } from "@prismicio/client";
|
|
2
|
-
import type {
|
|
3
|
-
LinkResolverFunction,
|
|
4
|
-
HTMLFunctionSerializer,
|
|
5
|
-
HTMLMapSerializer,
|
|
6
|
-
} from "@prismicio/helpers";
|
|
7
|
-
// import type * as prismicH from "@prismicio/helpers";
|
|
8
|
-
|
|
9
|
-
export interface Route {
|
|
10
|
-
/**
|
|
11
|
-
* The Custom Type of the document.
|
|
12
|
-
*/
|
|
13
|
-
type: string;
|
|
14
|
-
/**
|
|
15
|
-
* The resolved path of the document with optional placeholders.
|
|
16
|
-
*/
|
|
17
|
-
path: string;
|
|
18
|
-
/**
|
|
19
|
-
* An object that lists the API IDs of the Content Relationships in the route.
|
|
20
|
-
*/
|
|
21
|
-
resolvers: Record<string, string>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface PrismicConfig {
|
|
25
|
-
repoName: string;
|
|
26
|
-
routes?: Route[];
|
|
27
|
-
accessToken?: string;
|
|
28
|
-
options?: null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type PrismicContext = {
|
|
32
|
-
client?: Client;
|
|
33
|
-
linkResolver?: LinkResolverFunction;
|
|
34
|
-
htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
|
|
35
|
-
};
|
package/src/routes/index.svelte
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
import type * as prismicT from "@prismicio/types"
|
|
3
|
-
import { SliceZone } from "$lib";
|
|
4
|
-
import {RichText, CodeSnippet} from "./slices"
|
|
5
|
-
|
|
6
|
-
const components = {
|
|
7
|
-
rich_text: RichText,
|
|
8
|
-
code_snippet: CodeSnippet
|
|
9
|
-
}
|
|
10
|
-
</script>
|
|
11
|
-
|
|
12
|
-
<script lang="ts">
|
|
13
|
-
export let document:prismicT.PrismicDocument
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<main>
|
|
17
|
-
<h1>Welcome to SvelteKit</h1>
|
|
18
|
-
<SliceZone slices={document.data.body} {components} />
|
|
19
|
-
</main>
|
|
20
|
-
|
|
21
|
-
<style>
|
|
22
|
-
main {
|
|
23
|
-
max-width: min(90%, 800px);
|
|
24
|
-
margin: auto;
|
|
25
|
-
}
|
|
26
|
-
</style>
|
package/src/routes/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as prismic from "@prismicio/client";
|
|
2
|
-
import type * as prismicT from "@prismicio/types";
|
|
3
|
-
|
|
4
|
-
export async function get({ fetch }) {
|
|
5
|
-
const endpoint = prismic.getEndpoint("svelte-package-dev");
|
|
6
|
-
const client = prismic.createClient(endpoint, { fetch });
|
|
7
|
-
|
|
8
|
-
const document: prismicT.PrismicDocument = await client.getSingle("homepage");
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
body: {
|
|
12
|
-
document,
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import * as prismicH from "@prismicio/helpers"
|
|
3
|
-
import type * as prismicT from "@prismicio/types"
|
|
4
|
-
|
|
5
|
-
export let slice:prismicT.Slice
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<pre>
|
|
9
|
-
{@html prismicH.asHTML(slice.primary.content)}
|
|
10
|
-
</pre>
|
|
11
|
-
|
|
12
|
-
<style>
|
|
13
|
-
pre {
|
|
14
|
-
background: #222;
|
|
15
|
-
color: white;
|
|
16
|
-
padding: 10px;
|
|
17
|
-
border-radius: 10px;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
package/types.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Client } from "@prismicio/client";
|
|
2
|
-
import type { LinkResolverFunction, HTMLFunctionSerializer, HTMLMapSerializer } from "@prismicio/helpers";
|
|
3
|
-
export interface Route {
|
|
4
|
-
/**
|
|
5
|
-
* The Custom Type of the document.
|
|
6
|
-
*/
|
|
7
|
-
type: string;
|
|
8
|
-
/**
|
|
9
|
-
* The resolved path of the document with optional placeholders.
|
|
10
|
-
*/
|
|
11
|
-
path: string;
|
|
12
|
-
/**
|
|
13
|
-
* An object that lists the API IDs of the Content Relationships in the route.
|
|
14
|
-
*/
|
|
15
|
-
resolvers: Record<string, string>;
|
|
16
|
-
}
|
|
17
|
-
export interface PrismicConfig {
|
|
18
|
-
repoName: string;
|
|
19
|
-
routes?: Route[];
|
|
20
|
-
accessToken?: string;
|
|
21
|
-
options?: null;
|
|
22
|
-
}
|
|
23
|
-
export declare type PrismicContext = {
|
|
24
|
-
client?: Client;
|
|
25
|
-
linkResolver?: LinkResolverFunction;
|
|
26
|
-
htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
|
|
27
|
-
};
|
package/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/usePrismic.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|