@datocms/svelte 1.2.2 → 1.4.0
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/README.md +1 -0
- package/package/components/Head/Head.svelte +14 -0
- package/package/components/Head/Head.svelte.d.ts +61 -0
- package/package/components/Head/README.md +68 -0
- package/package/components/Image/Image.svelte +172 -0
- package/package/components/Image/Image.svelte.d.ts +83 -0
- package/package/components/Image/Placeholder.svelte +30 -0
- package/package/components/Image/Placeholder.svelte.d.ts +22 -0
- package/package/components/Image/README.md +167 -0
- package/package/components/Image/Sizer.svelte +17 -0
- package/package/components/Image/Sizer.svelte.d.ts +19 -0
- package/package/components/Image/Source.svelte +6 -0
- package/package/components/Image/Source.svelte.d.ts +18 -0
- package/package/components/StructuredText/Node.svelte +112 -0
- package/package/components/StructuredText/Node.svelte.d.ts +22 -0
- package/package/components/StructuredText/README.md +201 -0
- package/package/components/StructuredText/StructuredText.svelte +15 -0
- package/package/components/StructuredText/StructuredText.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/Blockquote.svelte +5 -0
- package/package/components/StructuredText/nodes/Blockquote.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/Code.svelte +6 -0
- package/package/components/StructuredText/nodes/Code.svelte.d.ts +17 -0
- package/package/components/StructuredText/nodes/Heading.svelte +8 -0
- package/package/components/StructuredText/nodes/Heading.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/Link.svelte +20 -0
- package/package/components/StructuredText/nodes/Link.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/List.svelte +10 -0
- package/package/components/StructuredText/nodes/List.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/ListItem.svelte +5 -0
- package/package/components/StructuredText/nodes/ListItem.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/Paragraph.svelte +5 -0
- package/package/components/StructuredText/nodes/Paragraph.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/Root.svelte +5 -0
- package/package/components/StructuredText/nodes/Root.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/Span.svelte +49 -0
- package/package/components/StructuredText/nodes/Span.svelte.d.ts +19 -0
- package/package/components/StructuredText/nodes/ThematicBreak.svelte +5 -0
- package/package/components/StructuredText/nodes/ThematicBreak.svelte.d.ts +17 -0
- package/package/components/StructuredText/utils/Lines.svelte +11 -0
- package/package/components/StructuredText/utils/Lines.svelte.d.ts +16 -0
- package/package/components/VideoPlayer/README.md +127 -0
- package/package/components/VideoPlayer/VideoPlayer.svelte +138 -0
- package/package/components/VideoPlayer/VideoPlayer.svelte.d.ts +134 -0
- package/package/components/VideoPlayer/__tests__/VideoPlayer.svelte.test.d.ts +1 -0
- package/package/components/VideoPlayer/__tests__/VideoPlayer.svelte.test.js +132 -0
- package/package/components/VideoPlayer/__tests__/__snapshots__/VideoPlayer.svelte.test.ts.snap +230 -0
- package/package/index.d.ts +10 -0
- package/package/index.js +4 -0
- package/package.json +227 -216
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
class?: string | null | undefined;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number | null | undefined;
|
|
7
|
+
aspectRatio: number | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type SizerProps = typeof __propDef.props;
|
|
15
|
+
export type SizerEvents = typeof __propDef.events;
|
|
16
|
+
export type SizerSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Sizer extends SvelteComponentTyped<SizerProps, SizerEvents, SizerSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
srcset: string | null;
|
|
5
|
+
sizes: string | null;
|
|
6
|
+
type?: string | null | undefined;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export type SourceProps = typeof __propDef.props;
|
|
14
|
+
export type SourceEvents = typeof __propDef.events;
|
|
15
|
+
export type SourceSlots = typeof __propDef.slots;
|
|
16
|
+
export default class Source extends SvelteComponentTyped<SourceProps, SourceEvents, SourceSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<script context="module">import {
|
|
2
|
+
isBlock,
|
|
3
|
+
isBlockquote,
|
|
4
|
+
isCode,
|
|
5
|
+
isHeading,
|
|
6
|
+
isInlineItem,
|
|
7
|
+
isItemLink,
|
|
8
|
+
isLink,
|
|
9
|
+
isList,
|
|
10
|
+
isListItem,
|
|
11
|
+
isParagraph,
|
|
12
|
+
isRoot,
|
|
13
|
+
isSpan,
|
|
14
|
+
isThematicBreak,
|
|
15
|
+
RenderError
|
|
16
|
+
} from "datocms-structured-text-utils";
|
|
17
|
+
import Paragraph from "./nodes/Paragraph.svelte";
|
|
18
|
+
import Root from "./nodes/Root.svelte";
|
|
19
|
+
import Span from "./nodes/Span.svelte";
|
|
20
|
+
import Link from "./nodes/Link.svelte";
|
|
21
|
+
import List from "./nodes/List.svelte";
|
|
22
|
+
import Heading from "./nodes/Heading.svelte";
|
|
23
|
+
import Blockquote from "./nodes/Blockquote.svelte";
|
|
24
|
+
import ListItem from "./nodes/ListItem.svelte";
|
|
25
|
+
import ThematicBreak from "./nodes/ThematicBreak.svelte";
|
|
26
|
+
import Code from "./nodes/Code.svelte";
|
|
27
|
+
export const DEFAULT_COMPONENTS = [
|
|
28
|
+
[isParagraph, Paragraph],
|
|
29
|
+
[isRoot, Root],
|
|
30
|
+
[isSpan, Span],
|
|
31
|
+
[isLink, Link],
|
|
32
|
+
[isList, List],
|
|
33
|
+
[isHeading, Heading],
|
|
34
|
+
[isBlockquote, Blockquote],
|
|
35
|
+
[isListItem, ListItem],
|
|
36
|
+
[isThematicBreak, ThematicBreak],
|
|
37
|
+
[isCode, Code]
|
|
38
|
+
];
|
|
39
|
+
const throwRenderErrorForMissingComponent = (node) => {
|
|
40
|
+
if (isInlineItem(node)) {
|
|
41
|
+
throw new RenderError(
|
|
42
|
+
`The Structured Text document contains an 'inlineItem' node, but no component for rendering is specified!`,
|
|
43
|
+
node
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (isItemLink(node)) {
|
|
47
|
+
throw new RenderError(
|
|
48
|
+
`The Structured Text document contains an 'itemLink' node, but no component for rendering is specified!`,
|
|
49
|
+
node
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if (isBlock(node)) {
|
|
53
|
+
throw new RenderError(
|
|
54
|
+
`The Structured Text document contains a 'block' node, but no component for rendering is specified!`,
|
|
55
|
+
node
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const throwRenderErrorForMissingBlock = (node) => {
|
|
60
|
+
throw new RenderError(
|
|
61
|
+
`The Structured Text document contains a 'block' node, but cannot find a record with ID ${node.item} inside data.blocks!`,
|
|
62
|
+
node
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
const throwRenderErrorForMissingLink = (node) => {
|
|
66
|
+
throw new RenderError(
|
|
67
|
+
`The Structured Text document contains an 'itemLink' node, but cannot find a record with ID ${node.item} inside data.links!`,
|
|
68
|
+
node
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
const findBlock = (node, blocks) => (blocks || []).find(({ id }) => id === node.item);
|
|
72
|
+
const findLink = (node, links) => (links || []).find(({ id }) => id === node.item);
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<script>import { hasChildren } from "datocms-structured-text-utils";
|
|
76
|
+
export let node;
|
|
77
|
+
export let blocks;
|
|
78
|
+
export let links;
|
|
79
|
+
export let components = [];
|
|
80
|
+
$:
|
|
81
|
+
block = isBlock(node) && (findBlock(node, blocks) || throwRenderErrorForMissingBlock(node));
|
|
82
|
+
$:
|
|
83
|
+
link = isItemLink(node) && (findLink(node, links) || throwRenderErrorForMissingLink(node)) || isInlineItem(node) && (findLink(node, links) || throwRenderErrorForMissingLink(node));
|
|
84
|
+
$:
|
|
85
|
+
predicateComponentTuple = [...components, ...DEFAULT_COMPONENTS].find(([predicate, component2]) => predicate(node)) || throwRenderErrorForMissingComponent(node);
|
|
86
|
+
$:
|
|
87
|
+
component = (predicateComponentTuple ?? [])[1];
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
{#if component}
|
|
91
|
+
{#if isBlock(node)}
|
|
92
|
+
<svelte:component this={component} {node} {block} />
|
|
93
|
+
{:else if isInlineItem(node)}
|
|
94
|
+
<svelte:component this={component} {node} {link} />
|
|
95
|
+
{:else if isItemLink(node)}
|
|
96
|
+
<svelte:component this={component} {node} {link}>
|
|
97
|
+
{#if hasChildren(node)}
|
|
98
|
+
{#each node.children as child}
|
|
99
|
+
<svelte:self node={child} {blocks} {links} {components} />
|
|
100
|
+
{/each}
|
|
101
|
+
{/if}
|
|
102
|
+
</svelte:component>
|
|
103
|
+
{:else}
|
|
104
|
+
<svelte:component this={component} {node}>
|
|
105
|
+
{#if hasChildren(node)}
|
|
106
|
+
{#each node.children as child}
|
|
107
|
+
<svelte:self node={child} {blocks} {links} {components} />
|
|
108
|
+
{/each}
|
|
109
|
+
{/if}
|
|
110
|
+
</svelte:component>
|
|
111
|
+
{/if}
|
|
112
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
export declare const DEFAULT_COMPONENTS: PredicateComponentTuple[];
|
|
3
|
+
import { type Node, type StructuredText } from 'datocms-structured-text-utils';
|
|
4
|
+
import type { PredicateComponentTuple } from '../..';
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
node: Node;
|
|
8
|
+
blocks: StructuredText['blocks'];
|
|
9
|
+
links: StructuredText['links'];
|
|
10
|
+
components?: PredicateComponentTuple[] | undefined;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {};
|
|
16
|
+
};
|
|
17
|
+
export type NodeProps = typeof __propDef.props;
|
|
18
|
+
export type NodeEvents = typeof __propDef.events;
|
|
19
|
+
export type NodeSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Node extends SvelteComponentTyped<NodeProps, NodeEvents, NodeSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Structured text
|
|
2
|
+
|
|
3
|
+
`StructuredText />` is a Svelte component that you can use to render the value contained inside a DatoCMS [Structured Text field type](https://www.datocms.com/docs/structured-text/dast).
|
|
4
|
+
|
|
5
|
+
### Table of contents
|
|
6
|
+
|
|
7
|
+
- [Setup](#setup)
|
|
8
|
+
- [Basic usage](#basic-usage)
|
|
9
|
+
- [Custom renderers](#custom-renderers)
|
|
10
|
+
- [Props](#props)
|
|
11
|
+
|
|
12
|
+
### Setup
|
|
13
|
+
|
|
14
|
+
Import the component like this:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { StructuredText } from '@datocms/svelte';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Basic usage
|
|
21
|
+
|
|
22
|
+
```svelte
|
|
23
|
+
<script>
|
|
24
|
+
|
|
25
|
+
import { onMount } from 'svelte';
|
|
26
|
+
|
|
27
|
+
import { StructuredText } from '@datocms/svelte';
|
|
28
|
+
|
|
29
|
+
const query = `
|
|
30
|
+
query {
|
|
31
|
+
blogPost {
|
|
32
|
+
title
|
|
33
|
+
content {
|
|
34
|
+
value
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export let data = null;
|
|
41
|
+
|
|
42
|
+
onMount(async () => {
|
|
43
|
+
const response = await fetch('https://graphql.datocms.com/', {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
Authorization: "Bearer faeb9172e232a75339242faafb9e56de8c8f13b735f7090964",
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify({ query })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const json = await response.json()
|
|
53
|
+
|
|
54
|
+
data = json.data;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<article>
|
|
60
|
+
{#if data}
|
|
61
|
+
<h1>{{ data.blogPost.title }}</h1>
|
|
62
|
+
<StructuredText data={data.blogPost.content} />
|
|
63
|
+
{/if}
|
|
64
|
+
</article>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Customization
|
|
68
|
+
|
|
69
|
+
The `<StructuredText />` component comes with a set of default components that are use to render all the nodes present in [DatoCMS Dast trees](https://www.datocms.com/docs/structured-text/dast). These default components are enough to cover most of the simple cases.
|
|
70
|
+
|
|
71
|
+
You need to use custom components in the following cases:
|
|
72
|
+
|
|
73
|
+
- you have to render blocks, inline items or item links: there's no conventional way of rendering theses nodes, so you must create and pass custom components;
|
|
74
|
+
- you need to render a conventional node differently (e.g. you may want a custom render for blockquotes)
|
|
75
|
+
|
|
76
|
+
### Custom components for blocks
|
|
77
|
+
|
|
78
|
+
Here is an example using custom components for blocks, inline and item links. Take a look at the [test fixtures](https://github.com/datocms/datocms-svelte/tree/main/src/lib/components/StructuredText/__tests__/__fixtures__) to see examples on how to implement these components.
|
|
79
|
+
|
|
80
|
+
```svelte
|
|
81
|
+
<script>
|
|
82
|
+
|
|
83
|
+
import { onMount } from 'svelte';
|
|
84
|
+
|
|
85
|
+
import { isBlock, isInlineItem, isItemLink } from 'datocms-structured-text-utils';
|
|
86
|
+
|
|
87
|
+
import { StructuredText } from '@datocms/svelte';
|
|
88
|
+
|
|
89
|
+
import Block from './Block.svelte';
|
|
90
|
+
import InlineItem from './InlineItem.svelte';
|
|
91
|
+
import ItemLink from './ItemLink.svelte';
|
|
92
|
+
|
|
93
|
+
const query = `
|
|
94
|
+
query {
|
|
95
|
+
blogPost {
|
|
96
|
+
title
|
|
97
|
+
content {
|
|
98
|
+
value
|
|
99
|
+
links {
|
|
100
|
+
__typename
|
|
101
|
+
... on TeamMemberRecord {
|
|
102
|
+
id
|
|
103
|
+
firstName
|
|
104
|
+
slug
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
blocks {
|
|
108
|
+
__typename
|
|
109
|
+
... on ImageRecord {
|
|
110
|
+
id
|
|
111
|
+
image {
|
|
112
|
+
responsiveImage(
|
|
113
|
+
imgixParams: { fit: crop, w: 300, h: 300, auto: format }
|
|
114
|
+
) {
|
|
115
|
+
srcSet
|
|
116
|
+
webpSrcSet
|
|
117
|
+
sizes
|
|
118
|
+
src
|
|
119
|
+
width
|
|
120
|
+
height
|
|
121
|
+
aspectRatio
|
|
122
|
+
alt
|
|
123
|
+
title
|
|
124
|
+
base64
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
export let data = null;
|
|
135
|
+
|
|
136
|
+
onMount(async () => {
|
|
137
|
+
const response = await fetch('https://graphql.datocms.com/', {
|
|
138
|
+
method: 'POST',
|
|
139
|
+
headers: {
|
|
140
|
+
'Content-Type': 'application/json',
|
|
141
|
+
Authorization: "Bearer faeb9172e232a75339242faafb9e56de8c8f13b735f7090964",
|
|
142
|
+
},
|
|
143
|
+
body: JSON.stringify({ query })
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const json = await response.json()
|
|
147
|
+
|
|
148
|
+
data = json.data;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
</script>
|
|
152
|
+
|
|
153
|
+
<article>
|
|
154
|
+
{#if data}
|
|
155
|
+
<h1>{{ data.blogPost.title }}</h1>
|
|
156
|
+
<datocms-structured-text
|
|
157
|
+
data={data.blogPost.content}
|
|
158
|
+
components={[
|
|
159
|
+
[isInlineItem, InlineItem],
|
|
160
|
+
[isItemLink, ItemLink],
|
|
161
|
+
[isBlock, Block]
|
|
162
|
+
]}
|
|
163
|
+
/>
|
|
164
|
+
{/if}
|
|
165
|
+
</article>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Override default rendering of nodes
|
|
169
|
+
|
|
170
|
+
`<StructuredText />` automatically renders all nodes (except for `inline_item`, `item_link` and `block`) using a set of default components, that you might want to customize. For example:
|
|
171
|
+
|
|
172
|
+
- For `heading` nodes, you might want to add an anchor;
|
|
173
|
+
- For `code` nodes, you might want to use a custom syntax highlighting component;
|
|
174
|
+
|
|
175
|
+
In this case, you can easily override default rendering rules with the `components` props. See test fixtures for example implementations of custom components (e.g. [this special heading component](https://github.com/datocms/datocms-svelte/blob/main/src/lib/components/StructuredText/__tests__/__fixtures__/IncreasedLevelHeading.svelte)).
|
|
176
|
+
|
|
177
|
+
```svelte
|
|
178
|
+
<script>
|
|
179
|
+
import { isHeading, isCode } from 'datocms-structured-text-utils';
|
|
180
|
+
|
|
181
|
+
import Heading from './Heading.svelte';
|
|
182
|
+
import Code from './Code.svelte';
|
|
183
|
+
|
|
184
|
+
export let data;
|
|
185
|
+
</script>
|
|
186
|
+
|
|
187
|
+
<StructuredText
|
|
188
|
+
data={data.blogPost.content}
|
|
189
|
+
components={[
|
|
190
|
+
[isHeading, Heading],
|
|
191
|
+
[isCode, Code]
|
|
192
|
+
]}
|
|
193
|
+
/>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Props
|
|
197
|
+
|
|
198
|
+
| prop | type | required | description | default |
|
|
199
|
+
| ---------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------- |
|
|
200
|
+
| data | `StructuredText \| DastNode` | :white_check_mark: | The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from DatoCMS | |
|
|
201
|
+
| components | [`PredicateComponentTuple[] \| null`](https://github.com/datocms/datocms-svelte/blob/main/src/lib/index.ts) | Only required if data contain `block`, `inline_item` or `item_link` nodes | Array of tuples formed by a predicate function and custom component | `[]` |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script>import { isStructuredText } from "datocms-structured-text-utils";
|
|
2
|
+
import Node from "./Node.svelte";
|
|
3
|
+
export let data = null;
|
|
4
|
+
export let components = [];
|
|
5
|
+
$:
|
|
6
|
+
node = data != null && (isStructuredText(data) ? data.value : data).document;
|
|
7
|
+
$:
|
|
8
|
+
blocks = isStructuredText(data) ? data?.blocks : void 0;
|
|
9
|
+
$:
|
|
10
|
+
links = isStructuredText(data) ? data?.links : void 0;
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
{#if node}
|
|
14
|
+
<Node {node} {blocks} {links} {components} />
|
|
15
|
+
{/if}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type StructuredText, type Document } from 'datocms-structured-text-utils';
|
|
3
|
+
import type { PredicateComponentTuple } from '../..';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
/** The actual field value you get from DatoCMS **/ data?: StructuredText | Document | null | undefined;
|
|
7
|
+
components?: PredicateComponentTuple[] | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type StructuredTextProps = typeof __propDef.props;
|
|
15
|
+
export type StructuredTextEvents = typeof __propDef.events;
|
|
16
|
+
export type StructuredTextSlots = typeof __propDef.slots;
|
|
17
|
+
export default class StructuredText extends SvelteComponentTyped<StructuredTextProps, StructuredTextEvents, StructuredTextSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Blockquote } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: Blockquote;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type BlockquoteProps = typeof __propDef.props;
|
|
15
|
+
export type BlockquoteEvents = typeof __propDef.events;
|
|
16
|
+
export type BlockquoteSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Blockquote extends SvelteComponentTyped<BlockquoteProps, BlockquoteEvents, BlockquoteSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Code } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: Code;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type CodeProps = typeof __propDef.props;
|
|
13
|
+
export type CodeEvents = typeof __propDef.events;
|
|
14
|
+
export type CodeSlots = typeof __propDef.slots;
|
|
15
|
+
export default class Code extends SvelteComponentTyped<CodeProps, CodeEvents, CodeSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Heading } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: Heading;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type HeadingProps = typeof __propDef.props;
|
|
15
|
+
export type HeadingEvents = typeof __propDef.events;
|
|
16
|
+
export type HeadingSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Heading extends SvelteComponentTyped<HeadingProps, HeadingEvents, HeadingSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script>export let node;
|
|
2
|
+
$:
|
|
3
|
+
({ url, meta } = node);
|
|
4
|
+
let target = void 0;
|
|
5
|
+
$: {
|
|
6
|
+
const targetMetaEntry = meta?.find((metaEntry) => metaEntry.id === "target");
|
|
7
|
+
if (targetMetaEntry?.value) {
|
|
8
|
+
target = targetMetaEntry.value;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
let rel = void 0;
|
|
12
|
+
$: {
|
|
13
|
+
const relMetaEntry = meta?.find((metaEntry) => metaEntry.id === "rel");
|
|
14
|
+
if (relMetaEntry?.value) {
|
|
15
|
+
rel = relMetaEntry.value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<a href={url} {target} {rel}><slot /></a>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Link } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: Link;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type LinkProps = typeof __propDef.props;
|
|
15
|
+
export type LinkEvents = typeof __propDef.events;
|
|
16
|
+
export type LinkSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Link extends SvelteComponentTyped<LinkProps, LinkEvents, LinkSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { List } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: List;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type ListProps = typeof __propDef.props;
|
|
15
|
+
export type ListEvents = typeof __propDef.events;
|
|
16
|
+
export type ListSlots = typeof __propDef.slots;
|
|
17
|
+
export default class List extends SvelteComponentTyped<ListProps, ListEvents, ListSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { ListItem } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: ListItem;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type ListItemProps = typeof __propDef.props;
|
|
15
|
+
export type ListItemEvents = typeof __propDef.events;
|
|
16
|
+
export type ListItemSlots = typeof __propDef.slots;
|
|
17
|
+
export default class ListItem extends SvelteComponentTyped<ListItemProps, ListItemEvents, ListItemSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Paragraph } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: Paragraph;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type ParagraphProps = typeof __propDef.props;
|
|
15
|
+
export type ParagraphEvents = typeof __propDef.events;
|
|
16
|
+
export type ParagraphSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Paragraph extends SvelteComponentTyped<ParagraphProps, ParagraphEvents, ParagraphSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Root } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: Root;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type RootProps = typeof __propDef.props;
|
|
15
|
+
export type RootEvents = typeof __propDef.events;
|
|
16
|
+
export type RootSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Root extends SvelteComponentTyped<RootProps, RootEvents, RootSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|