@datocms/astro 0.6.7 → 0.6.8
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/package.json +5 -3
- package/src/ContentLink/ContentLink.astro +38 -6
- package/src/ContentLink/README.md +32 -4
- package/src/StructuredText/Node.astro +25 -9
- package/src/StructuredText/StructuredText.astro +8 -9
- package/src/StructuredText/ensureValidStructuredTextProps.ts +18 -14
- package/src/StructuredText/nodes/Block.astro +7 -3
- package/src/StructuredText/nodes/InlineBlock.astro +7 -3
- package/src/StructuredText/nodes/InlineItem.astro +7 -3
- package/src/StructuredText/nodes/ItemLink.astro +7 -3
- package/src/StructuredText/types.ts +31 -27
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@datocms/astro",
|
|
3
3
|
"description": "A set of components and utilities to work faster with DatoCMS in Astro projects.",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.6.
|
|
5
|
+
"version": "0.6.8",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"prepare": "npx simple-git-hooks",
|
|
27
27
|
"lint": "prettier --check .",
|
|
28
|
+
"build": "npx astro check",
|
|
28
29
|
"format": "npm run toc && npx prettier . --write",
|
|
29
30
|
"toc": "doctoc --github README.md src",
|
|
30
31
|
"test": "echo 1"
|
|
@@ -54,13 +55,14 @@
|
|
|
54
55
|
"astro": "*"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"astro": "^
|
|
58
|
+
"astro": "^5.16.15",
|
|
58
59
|
"doctoc": "^2.2.1",
|
|
59
60
|
"np": "^10.0.7",
|
|
60
61
|
"prettier": "^3.3.3",
|
|
61
62
|
"prettier-plugin-astro": "^0.14.1",
|
|
62
63
|
"simple-git-hooks": "^2.11.1",
|
|
63
|
-
"typescript": "^5.
|
|
64
|
+
"typescript": "^5.9.3",
|
|
65
|
+
"@astrojs/check": "^0.9.6"
|
|
64
66
|
},
|
|
65
67
|
"simple-git-hooks": {
|
|
66
68
|
"pre-commit": "npm run format"
|
|
@@ -28,21 +28,48 @@
|
|
|
28
28
|
* @see https://www.datocms.com/marketplace/plugins/i/datocms-plugin-web-previews
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
+
export interface ClickToEditOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Whether to automatically scroll to the nearest editable element if none
|
|
34
|
+
* is currently visible in the viewport when click-to-edit mode is enabled.
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
scrollToNearestTarget?: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Only enable click-to-edit on devices that support hover (i.e., non-touch devices).
|
|
42
|
+
* Uses `window.matchMedia('(hover: hover)')` to detect hover capability.
|
|
43
|
+
*
|
|
44
|
+
* This is useful to avoid showing overlays on touch devices where they may
|
|
45
|
+
* interfere with normal scrolling and tapping behavior.
|
|
46
|
+
*
|
|
47
|
+
* When set to `true` on a touch-only device, click-to-edit will not be
|
|
48
|
+
* automatically enabled, but users can still toggle it manually using
|
|
49
|
+
* the Alt/Option key.
|
|
50
|
+
*
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
hoverOnly?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
31
56
|
export interface Props {
|
|
32
57
|
/**
|
|
33
58
|
* Whether to enable click-to-edit overlays on mount, or options to configure them.
|
|
34
59
|
*
|
|
35
60
|
* - `true`: Enable click-to-edit mode immediately
|
|
36
61
|
* - `{ scrollToNearestTarget: true }`: Enable and scroll to nearest editable if none visible
|
|
37
|
-
* - `
|
|
62
|
+
* - `{ hoverOnly: true }`: Only enable on devices with hover capability (non-touch)
|
|
63
|
+
* - `false`/`undefined`: Don't enable automatically (use Alt/Option key to toggle)
|
|
38
64
|
*
|
|
39
65
|
* @example
|
|
40
66
|
* ```astro
|
|
41
67
|
* <ContentLink enableClickToEdit={true} />
|
|
42
68
|
* <ContentLink enableClickToEdit={{ scrollToNearestTarget: true }} />
|
|
69
|
+
* <ContentLink enableClickToEdit={{ hoverOnly: true, scrollToNearestTarget: true }} />
|
|
43
70
|
* ```
|
|
44
71
|
*/
|
|
45
|
-
enableClickToEdit?: boolean |
|
|
72
|
+
enableClickToEdit?: boolean | ClickToEditOptions;
|
|
46
73
|
|
|
47
74
|
/**
|
|
48
75
|
* Whether to strip stega-encoded invisible characters from text content after stamping.
|
|
@@ -146,10 +173,15 @@ const enableClickToEditValue =
|
|
|
146
173
|
|
|
147
174
|
// Enable click-to-edit mode if requested via prop
|
|
148
175
|
if (enableClickToEdit) {
|
|
149
|
-
if
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
176
|
+
// Check if hoverOnly is set and device doesn't support hover
|
|
177
|
+
const hoverOnly = typeof enableClickToEdit === 'object' && enableClickToEdit.hoverOnly;
|
|
178
|
+
|
|
179
|
+
if (!hoverOnly || window.matchMedia('(hover: hover)').matches) {
|
|
180
|
+
if (enableClickToEdit === true) {
|
|
181
|
+
this.controller.enableClickToEdit();
|
|
182
|
+
} else {
|
|
183
|
+
this.controller.enableClickToEdit(enableClickToEdit);
|
|
184
|
+
}
|
|
153
185
|
}
|
|
154
186
|
}
|
|
155
187
|
// Otherwise, click-to-edit overlays are not enabled by default.
|
|
@@ -31,6 +31,7 @@ Visual Editing transforms how editors interact with your content by letting them
|
|
|
31
31
|
- [Step 2: Add the ContentLink component](#step-2-add-the-contentlink-component)
|
|
32
32
|
- [Usage](#usage)
|
|
33
33
|
- [Props](#props)
|
|
34
|
+
- [`enableClickToEdit` options](#enableclicktoedit-options)
|
|
34
35
|
- [StructuredText integration](#structuredtext-integration)
|
|
35
36
|
- [Edit groups with `data-datocms-content-link-group`](#edit-groups-with-data-datocms-content-link-group)
|
|
36
37
|
- [Edit boundaries with `data-datocms-content-link-boundary`](#edit-boundaries-with-data-datocms-content-link-boundary)
|
|
@@ -140,10 +141,37 @@ You get the full Visual Editing experience regardless of your routing setup.
|
|
|
140
141
|
|
|
141
142
|
## Props
|
|
142
143
|
|
|
143
|
-
| Prop | Type
|
|
144
|
-
| ------------------- |
|
|
145
|
-
| `enableClickToEdit` | `boolean \| { scrollToNearestTarget?: boolean }` | - | Enable click-to-edit overlays on mount. Use `true` for immediate activation, or pass options
|
|
146
|
-
| `stripStega` | `boolean`
|
|
144
|
+
| Prop | Type | Default | Description |
|
|
145
|
+
| ------------------- | --------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
146
|
+
| `enableClickToEdit` | `boolean \| { scrollToNearestTarget?: boolean; hoverOnly?: boolean }` | - | Enable click-to-edit overlays on mount. Use `true` for immediate activation, or pass options object (see below) |
|
|
147
|
+
| `stripStega` | `boolean` | `false` | Strip stega-encoded invisible characters from text content. When `true`, encoding is permanently removed (prevents controller recreation) |
|
|
148
|
+
|
|
149
|
+
### `enableClickToEdit` options
|
|
150
|
+
|
|
151
|
+
When passing an options object to `enableClickToEdit`, the following properties are available:
|
|
152
|
+
|
|
153
|
+
| Option | Type | Default | Description |
|
|
154
|
+
| ----------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
155
|
+
| `scrollToNearestTarget` | `boolean` | `false` | Automatically scroll to the nearest editable element if none is currently visible in the viewport when click-to-edit mode is enabled |
|
|
156
|
+
| `hoverOnly` | `boolean` | `false` | Only enable click-to-edit on devices that support hover (non-touch). Uses `window.matchMedia('(hover: hover)')` to detect hover capability. On touch devices, users can still toggle with Alt/Option |
|
|
157
|
+
|
|
158
|
+
**Examples:**
|
|
159
|
+
|
|
160
|
+
```astro
|
|
161
|
+
<!-- Enable click-to-edit immediately -->
|
|
162
|
+
<ContentLink enableClickToEdit={true} />
|
|
163
|
+
|
|
164
|
+
<!-- Enable with scroll-to-nearest behavior -->
|
|
165
|
+
<ContentLink enableClickToEdit={{ scrollToNearestTarget: true }} />
|
|
166
|
+
|
|
167
|
+
<!-- Only enable on devices with hover capability (recommended for sites with touch users) -->
|
|
168
|
+
<ContentLink enableClickToEdit={{ hoverOnly: true }} />
|
|
169
|
+
|
|
170
|
+
<!-- Combine both options -->
|
|
171
|
+
<ContentLink enableClickToEdit={{ hoverOnly: true, scrollToNearestTarget: true }} />
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The `hoverOnly` option is particularly useful for websites that receive traffic from both desktop and mobile users. On touch devices, the click-to-edit overlays can interfere with normal scrolling and tapping behavior. By setting `hoverOnly: true`, overlays will only appear automatically on devices with a mouse or trackpad, while touch device users can still access click-to-edit mode by pressing and holding the Alt/Option key.
|
|
147
175
|
|
|
148
176
|
## StructuredText integration
|
|
149
177
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
type Block,
|
|
4
4
|
type InlineBlock,
|
|
5
|
-
type
|
|
5
|
+
type CdaStructuredTextRecord,
|
|
6
6
|
type InlineItem,
|
|
7
7
|
type ItemLink,
|
|
8
8
|
type Node as DastNode,
|
|
@@ -44,14 +44,30 @@ import type {
|
|
|
44
44
|
interface Props {
|
|
45
45
|
node: DastNode;
|
|
46
46
|
|
|
47
|
-
blocks?:
|
|
48
|
-
inlineBlocks?:
|
|
49
|
-
links?:
|
|
50
|
-
|
|
51
|
-
blockComponents?: BlockComponents<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
blocks?: CdaStructuredTextRecord[];
|
|
48
|
+
inlineBlocks?: CdaStructuredTextRecord[];
|
|
49
|
+
links?: CdaStructuredTextRecord[];
|
|
50
|
+
|
|
51
|
+
blockComponents?: BlockComponents<
|
|
52
|
+
CdaStructuredTextRecord,
|
|
53
|
+
CdaStructuredTextRecord,
|
|
54
|
+
CdaStructuredTextRecord
|
|
55
|
+
>;
|
|
56
|
+
inlineBlockComponents?: InlineBlockComponents<
|
|
57
|
+
CdaStructuredTextRecord,
|
|
58
|
+
CdaStructuredTextRecord,
|
|
59
|
+
CdaStructuredTextRecord
|
|
60
|
+
>;
|
|
61
|
+
linkToRecordComponents?: LinkToRecordComponents<
|
|
62
|
+
CdaStructuredTextRecord,
|
|
63
|
+
CdaStructuredTextRecord,
|
|
64
|
+
CdaStructuredTextRecord
|
|
65
|
+
>;
|
|
66
|
+
inlineRecordComponents?: InlineRecordComponents<
|
|
67
|
+
CdaStructuredTextRecord,
|
|
68
|
+
CdaStructuredTextRecord,
|
|
69
|
+
CdaStructuredTextRecord
|
|
70
|
+
>;
|
|
55
71
|
|
|
56
72
|
nodeOverrides?: NodeOverrides;
|
|
57
73
|
markOverrides?: MarkOverrides;
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
type Node as DastNode,
|
|
4
4
|
type Document,
|
|
5
|
-
type
|
|
6
|
-
type StructuredText,
|
|
5
|
+
type CdaStructuredTextValue,
|
|
7
6
|
isDocument,
|
|
8
7
|
isNode,
|
|
9
|
-
|
|
8
|
+
isCdaStructuredTextValue,
|
|
10
9
|
} from 'datocms-structured-text-utils';
|
|
11
10
|
|
|
12
11
|
import Node from './Node.astro';
|
|
@@ -14,7 +13,7 @@ import type { NodeOverrides, MarkOverrides, AstroComponent } from './types';
|
|
|
14
13
|
|
|
15
14
|
// It would be better to type this as a generic:
|
|
16
15
|
//
|
|
17
|
-
// interface Props<
|
|
16
|
+
// interface Props<B extends CdaStructuredTextRecord = any, L extends CdaStructuredTextRecord = any, I extends CdaStructuredTextRecord = any>
|
|
18
17
|
//
|
|
19
18
|
// but it's currently not possible: https://github.com/withastro/roadmap/discussions/601#discussioncomment-10333959
|
|
20
19
|
//
|
|
@@ -22,7 +21,7 @@ import type { NodeOverrides, MarkOverrides, AstroComponent } from './types';
|
|
|
22
21
|
|
|
23
22
|
interface Props {
|
|
24
23
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
25
|
-
data:
|
|
24
|
+
data: CdaStructuredTextValue | Document | DastNode | null | undefined;
|
|
26
25
|
|
|
27
26
|
/** An object in which the keys are the `__typename` of the blocks to be rendered, and the values are the Astro components */
|
|
28
27
|
blockComponents?: Record<string, AstroComponent>;
|
|
@@ -43,7 +42,7 @@ const { data, ...rest } = Astro.props;
|
|
|
43
42
|
|
|
44
43
|
const node = !data
|
|
45
44
|
? null
|
|
46
|
-
:
|
|
45
|
+
: isCdaStructuredTextValue(data) && isDocument(data.value)
|
|
47
46
|
? data.value.document
|
|
48
47
|
: isDocument(data)
|
|
49
48
|
? data.document
|
|
@@ -51,9 +50,9 @@ const node = !data
|
|
|
51
50
|
? data
|
|
52
51
|
: undefined;
|
|
53
52
|
|
|
54
|
-
const blocks =
|
|
55
|
-
const inlineBlocks =
|
|
56
|
-
const links =
|
|
53
|
+
const blocks = isCdaStructuredTextValue(data) ? data?.blocks : undefined;
|
|
54
|
+
const inlineBlocks = isCdaStructuredTextValue(data) ? data?.inlineBlocks : undefined;
|
|
55
|
+
const links = isCdaStructuredTextValue(data) ? data?.links : undefined;
|
|
57
56
|
---
|
|
58
57
|
|
|
59
58
|
{node && <Node {node} {blocks} {inlineBlocks} {links} {...rest} />}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Node as DastNode,
|
|
3
|
-
type
|
|
3
|
+
type CdaStructuredTextRecord,
|
|
4
4
|
type Document,
|
|
5
|
-
type
|
|
5
|
+
type CdaStructuredTextValue,
|
|
6
6
|
} from 'datocms-structured-text-utils';
|
|
7
7
|
import type {
|
|
8
8
|
BlockComponents,
|
|
@@ -11,11 +11,15 @@ import type {
|
|
|
11
11
|
LinkToRecordComponents,
|
|
12
12
|
} from './types';
|
|
13
13
|
|
|
14
|
-
type Props<
|
|
14
|
+
type Props<
|
|
15
|
+
B extends CdaStructuredTextRecord,
|
|
16
|
+
L extends CdaStructuredTextRecord,
|
|
17
|
+
I extends CdaStructuredTextRecord,
|
|
18
|
+
> =
|
|
15
19
|
| {
|
|
16
20
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
17
21
|
data:
|
|
18
|
-
| (Omit<
|
|
22
|
+
| (Omit<CdaStructuredTextValue<B, L, I>, 'blocks' | 'links' | 'inlineBlocks'> & {
|
|
19
23
|
blocks?: never;
|
|
20
24
|
links?: never;
|
|
21
25
|
inlineBlocks?: never;
|
|
@@ -32,7 +36,7 @@ type Props<B extends DatocmsRecord, L extends DatocmsRecord, I extends DatocmsRe
|
|
|
32
36
|
| {
|
|
33
37
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
34
38
|
data:
|
|
35
|
-
| (Omit<
|
|
39
|
+
| (Omit<CdaStructuredTextValue<B, L, I>, 'blocks' | 'links' | 'inlineBlocks'> & {
|
|
36
40
|
blocks: B[];
|
|
37
41
|
links?: never;
|
|
38
42
|
inlineBlocks?: never;
|
|
@@ -48,7 +52,7 @@ type Props<B extends DatocmsRecord, L extends DatocmsRecord, I extends DatocmsRe
|
|
|
48
52
|
| {
|
|
49
53
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
50
54
|
data:
|
|
51
|
-
| (Omit<
|
|
55
|
+
| (Omit<CdaStructuredTextValue<B, L, I>, 'blocks' | 'links' | 'inlineBlocks'> & {
|
|
52
56
|
blocks?: never;
|
|
53
57
|
links: L[];
|
|
54
58
|
inlineBlocks?: never;
|
|
@@ -65,7 +69,7 @@ type Props<B extends DatocmsRecord, L extends DatocmsRecord, I extends DatocmsRe
|
|
|
65
69
|
| {
|
|
66
70
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
67
71
|
data:
|
|
68
|
-
| (Omit<
|
|
72
|
+
| (Omit<CdaStructuredTextValue<B, L, I>, 'blocks' | 'links' | 'inlineBlocks'> & {
|
|
69
73
|
blocks?: never;
|
|
70
74
|
links?: never;
|
|
71
75
|
inlineBlocks: I[];
|
|
@@ -81,7 +85,7 @@ type Props<B extends DatocmsRecord, L extends DatocmsRecord, I extends DatocmsRe
|
|
|
81
85
|
| {
|
|
82
86
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
83
87
|
data:
|
|
84
|
-
| (Omit<
|
|
88
|
+
| (Omit<CdaStructuredTextValue<B, L, I>, 'blocks' | 'links' | 'inlineBlocks'> & {
|
|
85
89
|
blocks?: never;
|
|
86
90
|
links: L[];
|
|
87
91
|
inlineBlocks: I[];
|
|
@@ -99,7 +103,7 @@ type Props<B extends DatocmsRecord, L extends DatocmsRecord, I extends DatocmsRe
|
|
|
99
103
|
| {
|
|
100
104
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
101
105
|
data:
|
|
102
|
-
| (Omit<
|
|
106
|
+
| (Omit<CdaStructuredTextValue<B, L, I>, 'blocks' | 'links' | 'inlineBlocks'> & {
|
|
103
107
|
blocks: B[];
|
|
104
108
|
links?: never;
|
|
105
109
|
inlineBlocks: I[];
|
|
@@ -116,7 +120,7 @@ type Props<B extends DatocmsRecord, L extends DatocmsRecord, I extends DatocmsRe
|
|
|
116
120
|
| {
|
|
117
121
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
118
122
|
data:
|
|
119
|
-
| (Omit<
|
|
123
|
+
| (Omit<CdaStructuredTextValue<B, L, I>, 'blocks' | 'links' | 'inlineBlocks'> & {
|
|
120
124
|
blocks: B[];
|
|
121
125
|
links: L[];
|
|
122
126
|
inlineBlocks?: never;
|
|
@@ -134,7 +138,7 @@ type Props<B extends DatocmsRecord, L extends DatocmsRecord, I extends DatocmsRe
|
|
|
134
138
|
| {
|
|
135
139
|
/** The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from a DatoCMS Structured Text field */
|
|
136
140
|
data:
|
|
137
|
-
| (Omit<
|
|
141
|
+
| (Omit<CdaStructuredTextValue<B, L, I>, 'blocks' | 'links' | 'inlineBlocks'> & {
|
|
138
142
|
blocks: B[];
|
|
139
143
|
links: L[];
|
|
140
144
|
inlineBlocks: I[];
|
|
@@ -152,9 +156,9 @@ type Props<B extends DatocmsRecord, L extends DatocmsRecord, I extends DatocmsRe
|
|
|
152
156
|
};
|
|
153
157
|
|
|
154
158
|
export function ensureValidStructuredTextProps<
|
|
155
|
-
B extends
|
|
156
|
-
L extends
|
|
157
|
-
I extends
|
|
159
|
+
B extends CdaStructuredTextRecord = CdaStructuredTextRecord,
|
|
160
|
+
L extends CdaStructuredTextRecord = CdaStructuredTextRecord,
|
|
161
|
+
I extends CdaStructuredTextRecord = CdaStructuredTextRecord,
|
|
158
162
|
>(props: Props<B, L, I>): Props<B, L, I> {
|
|
159
163
|
return props;
|
|
160
164
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type CdaStructuredTextRecord,
|
|
4
4
|
RenderError,
|
|
5
5
|
type Block,
|
|
6
6
|
} from 'datocms-structured-text-utils';
|
|
@@ -8,8 +8,12 @@ import type { BlockComponents } from '../types';
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
node: Block;
|
|
11
|
-
block:
|
|
12
|
-
blockComponents?: BlockComponents<
|
|
11
|
+
block: CdaStructuredTextRecord;
|
|
12
|
+
blockComponents?: BlockComponents<
|
|
13
|
+
CdaStructuredTextRecord,
|
|
14
|
+
CdaStructuredTextRecord,
|
|
15
|
+
CdaStructuredTextRecord
|
|
16
|
+
>;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
const { node, block, blockComponents } = Astro.props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type CdaStructuredTextRecord,
|
|
4
4
|
RenderError,
|
|
5
5
|
type InlineBlock,
|
|
6
6
|
} from 'datocms-structured-text-utils';
|
|
@@ -8,8 +8,12 @@ import type { InlineBlockComponents } from '../types';
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
node: InlineBlock;
|
|
11
|
-
block:
|
|
12
|
-
inlineBlockComponents?: InlineBlockComponents<
|
|
11
|
+
block: CdaStructuredTextRecord;
|
|
12
|
+
inlineBlockComponents?: InlineBlockComponents<
|
|
13
|
+
CdaStructuredTextRecord,
|
|
14
|
+
CdaStructuredTextRecord,
|
|
15
|
+
CdaStructuredTextRecord
|
|
16
|
+
>;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
const { node, block, inlineBlockComponents } = Astro.props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type CdaStructuredTextRecord,
|
|
4
4
|
RenderError,
|
|
5
5
|
type InlineItem,
|
|
6
6
|
} from 'datocms-structured-text-utils';
|
|
@@ -8,8 +8,12 @@ import type { InlineRecordComponents } from '../types';
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
node: InlineItem;
|
|
11
|
-
record:
|
|
12
|
-
inlineRecordComponents?: InlineRecordComponents<
|
|
11
|
+
record: CdaStructuredTextRecord;
|
|
12
|
+
inlineRecordComponents?: InlineRecordComponents<
|
|
13
|
+
CdaStructuredTextRecord,
|
|
14
|
+
CdaStructuredTextRecord,
|
|
15
|
+
CdaStructuredTextRecord
|
|
16
|
+
>;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
const { node, record, inlineRecordComponents } = Astro.props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type CdaStructuredTextRecord,
|
|
4
4
|
RenderError,
|
|
5
5
|
type ItemLink,
|
|
6
6
|
} from 'datocms-structured-text-utils';
|
|
@@ -11,8 +11,12 @@ import { defaultMetaTransformer } from 'datocms-structured-text-generic-html-ren
|
|
|
11
11
|
|
|
12
12
|
interface Props {
|
|
13
13
|
node: ItemLink;
|
|
14
|
-
record:
|
|
15
|
-
linkToRecordComponents?: LinkToRecordComponents<
|
|
14
|
+
record: CdaStructuredTextRecord;
|
|
15
|
+
linkToRecordComponents?: LinkToRecordComponents<
|
|
16
|
+
CdaStructuredTextRecord,
|
|
17
|
+
CdaStructuredTextRecord,
|
|
18
|
+
CdaStructuredTextRecord
|
|
19
|
+
>;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
const { node, record, linkToRecordComponents } = Astro.props;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TransformedMeta } from 'datocms-structured-text-generic-html-renderer';
|
|
2
2
|
import type {
|
|
3
3
|
Block,
|
|
4
|
-
CdaStructuredTextRecord
|
|
4
|
+
CdaStructuredTextRecord,
|
|
5
5
|
InlineBlock,
|
|
6
6
|
InlineItem,
|
|
7
7
|
ItemLink,
|
|
@@ -14,25 +14,25 @@ import type {
|
|
|
14
14
|
export type AstroComponent<P = any> = (props: P) => any;
|
|
15
15
|
|
|
16
16
|
export type BlockComponents<
|
|
17
|
-
B extends
|
|
18
|
-
_L extends
|
|
19
|
-
_I extends
|
|
17
|
+
B extends CdaStructuredTextRecord,
|
|
18
|
+
_L extends CdaStructuredTextRecord,
|
|
19
|
+
_I extends CdaStructuredTextRecord,
|
|
20
20
|
> = {
|
|
21
21
|
[R in B as R['__typename']]: AstroComponent<{ block: R }>;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export type InlineBlockComponents<
|
|
25
|
-
_B extends
|
|
26
|
-
_L extends
|
|
27
|
-
I extends
|
|
25
|
+
_B extends CdaStructuredTextRecord,
|
|
26
|
+
_L extends CdaStructuredTextRecord,
|
|
27
|
+
I extends CdaStructuredTextRecord,
|
|
28
28
|
> = {
|
|
29
29
|
[R in I as R['__typename']]: AstroComponent<{ block: R }>;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export type LinkToRecordComponents<
|
|
33
|
-
_B extends
|
|
34
|
-
L extends
|
|
35
|
-
_I extends
|
|
33
|
+
_B extends CdaStructuredTextRecord,
|
|
34
|
+
L extends CdaStructuredTextRecord,
|
|
35
|
+
_I extends CdaStructuredTextRecord,
|
|
36
36
|
> = {
|
|
37
37
|
[R in L as R['__typename']]: AstroComponent<{
|
|
38
38
|
node: ItemLink;
|
|
@@ -42,9 +42,9 @@ export type LinkToRecordComponents<
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export type InlineRecordComponents<
|
|
45
|
-
_B extends
|
|
46
|
-
L extends
|
|
47
|
-
_I extends
|
|
45
|
+
_B extends CdaStructuredTextRecord,
|
|
46
|
+
L extends CdaStructuredTextRecord,
|
|
47
|
+
_I extends CdaStructuredTextRecord,
|
|
48
48
|
> = {
|
|
49
49
|
[R in L as R['__typename']]: AstroComponent<{ record: R }>;
|
|
50
50
|
};
|
|
@@ -54,28 +54,32 @@ export type NodeOverrides = Partial<{
|
|
|
54
54
|
N extends ItemLink
|
|
55
55
|
? {
|
|
56
56
|
node: ItemLink;
|
|
57
|
-
record:
|
|
57
|
+
record: CdaStructuredTextRecord;
|
|
58
58
|
linkToRecordComponents?: LinkToRecordComponents<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
CdaStructuredTextRecord,
|
|
60
|
+
CdaStructuredTextRecord,
|
|
61
|
+
CdaStructuredTextRecord
|
|
62
62
|
>;
|
|
63
63
|
}
|
|
64
64
|
: N extends InlineItem
|
|
65
65
|
? {
|
|
66
66
|
node: InlineItem;
|
|
67
|
-
record:
|
|
67
|
+
record: CdaStructuredTextRecord;
|
|
68
68
|
inlineRecordComponents?: InlineRecordComponents<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
CdaStructuredTextRecord,
|
|
70
|
+
CdaStructuredTextRecord,
|
|
71
|
+
CdaStructuredTextRecord
|
|
72
72
|
>;
|
|
73
73
|
}
|
|
74
74
|
: N extends Block
|
|
75
75
|
? {
|
|
76
76
|
node: Block;
|
|
77
|
-
block:
|
|
78
|
-
blockComponents?: BlockComponents<
|
|
77
|
+
block: CdaStructuredTextRecord;
|
|
78
|
+
blockComponents?: BlockComponents<
|
|
79
|
+
CdaStructuredTextRecord,
|
|
80
|
+
CdaStructuredTextRecord,
|
|
81
|
+
CdaStructuredTextRecord
|
|
82
|
+
>;
|
|
79
83
|
}
|
|
80
84
|
: N extends Span
|
|
81
85
|
? {
|
|
@@ -85,11 +89,11 @@ export type NodeOverrides = Partial<{
|
|
|
85
89
|
: N extends InlineBlock
|
|
86
90
|
? {
|
|
87
91
|
node: N;
|
|
88
|
-
block:
|
|
92
|
+
block: CdaStructuredTextRecord;
|
|
89
93
|
inlineBlockComponents: InlineBlockComponents<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
CdaStructuredTextRecord,
|
|
95
|
+
CdaStructuredTextRecord,
|
|
96
|
+
CdaStructuredTextRecord
|
|
93
97
|
>;
|
|
94
98
|
}
|
|
95
99
|
: { node: N }
|