-
Hello, im new to keystone. ive been playing around with it for few days and its saving my life. im trying to figure out how to connect component blocks to relationships storage: {
digital_ocean_spaces: {
kind: 's3',
type: "image",
endpoint: 'https://fra1.digitaloceanspaces.com/',
bucketName,
region,
accessKeyId,
secretAccessKey,
acl: "public-read",
}
} export const image = component({
label: 'Image',
schema: {
src: fields.relationship({
listKey: 'Image',
label: 'Image',
selection: 'image',
}),
alt: fields.text({
label: 'Alt Text',
}),
},
preview: function Image(props) {
console.log(props)
return <NotEditable>
<img src={props.fields.src.value ?? ''} alt={props.fields.alt.value ?? ''}/>
</NotEditable>
},
}) |
Beta Was this translation helpful? Give feedback.
Answered by
iNetJoJo
Jun 29, 2024
Replies: 1 comment
-
solved. i added virtual field to Image Image: list({
access: allowAll,
fields: {
name: text({
validation: {isRequired: true},
}),
altText: text(),
image: image({
storage: "digital_ocean_spaces"
}),
image_url: virtual({
field: graphql.field({
type: graphql.String,
resolve(item) {
return `${process.env.ASSET_BASE_URL}/${item.image_id}.${item.image_extension}`;
}
})
})
}
})
```
and now i can use it in component like this
```tsx
src: fields.relationship({
listKey: 'Image',
label: 'Image',
selection: "image_url"
}),
``` |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dcousens
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
solved. i added virtual field to Image