@datocms/astro 0.3.2 → 0.3.3
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
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
isInlineItem,
|
|
11
11
|
isItemLink,
|
|
12
12
|
RenderError,
|
|
13
|
+
type NodeType,
|
|
13
14
|
} from 'datocms-structured-text-utils';
|
|
14
15
|
|
|
15
16
|
import Blockquote from './nodes/Blockquote.astro';
|
|
@@ -26,7 +27,13 @@ import BlockComponent from './nodes/Block.astro';
|
|
|
26
27
|
import InlineItemComponent from './nodes/InlineItem.astro';
|
|
27
28
|
import ItemLinkComponent from './nodes/ItemLink.astro';
|
|
28
29
|
|
|
29
|
-
import type {
|
|
30
|
+
import type {
|
|
31
|
+
BlockComponents,
|
|
32
|
+
InlineItemComponents,
|
|
33
|
+
ItemLinkComponents,
|
|
34
|
+
Overrides,
|
|
35
|
+
AstroComponent,
|
|
36
|
+
} from './types';
|
|
30
37
|
|
|
31
38
|
interface Props {
|
|
32
39
|
node: DastNode;
|
|
@@ -71,7 +78,7 @@ function findRecordInLinks(node: ItemLink | InlineItem) {
|
|
|
71
78
|
return record;
|
|
72
79
|
}
|
|
73
80
|
|
|
74
|
-
const defaultComponents:
|
|
81
|
+
const defaultComponents: Record<NodeType, AstroComponent> = {
|
|
75
82
|
paragraph: Paragraph,
|
|
76
83
|
root: Root,
|
|
77
84
|
span: Span,
|
|
@@ -87,7 +94,11 @@ const defaultComponents: Overrides = {
|
|
|
87
94
|
block: BlockComponent,
|
|
88
95
|
};
|
|
89
96
|
|
|
90
|
-
const otherNodeComponents:
|
|
97
|
+
const otherNodeComponents: Record<NodeType, AstroComponent> = {
|
|
98
|
+
...defaultComponents,
|
|
99
|
+
...overrides,
|
|
100
|
+
};
|
|
101
|
+
|
|
91
102
|
const Component = otherNodeComponents[node.type];
|
|
92
103
|
---
|
|
93
104
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Record as DatocmsRecord, NodeType } from 'datocms-structured-text-utils';
|
|
2
2
|
|
|
3
3
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
4
|
-
type AstroComponent = (props: any) => any;
|
|
4
|
+
export type AstroComponent = (props: any) => any;
|
|
5
5
|
|
|
6
6
|
export type BlockComponents<R1 extends DatocmsRecord, R2 extends DatocmsRecord> = Record<
|
|
7
7
|
R1['__typename'],
|
|
@@ -18,4 +18,4 @@ export type InlineItemComponents<R1 extends DatocmsRecord, R2 extends DatocmsRec
|
|
|
18
18
|
AstroComponent
|
|
19
19
|
>;
|
|
20
20
|
|
|
21
|
-
export type Overrides = Record<NodeType, AstroComponent
|
|
21
|
+
export type Overrides = Partial<Record<NodeType, AstroComponent>>;
|