diff --git a/apps/web/src/lib/keystatic/component-block/cloud-image.tsx b/apps/web/src/lib/keystatic/component-block/cloud-image.tsx index 601aa9f..2d19f16 100644 --- a/apps/web/src/lib/keystatic/component-block/cloud-image.tsx +++ b/apps/web/src/lib/keystatic/component-block/cloud-image.tsx @@ -1,31 +1,33 @@ -/** @jsxRuntime classic */ import { component, fields } from '@keystatic/core'; -// biome-ignore lint/correctness/noUnusedImports: React is used by the classic JSX runtime. -import * as React from 'react'; + +import { CloudImage } from '../renderers/cloud-image'; export const cloudImage = component({ label: 'Cloud Image', preview({ fields }) { const src = fields.src.value; + // `CloudImage` calls `new URL(src)` and throws on any not-yet-valid URL + // (empty, whitespace-only, or missing protocol), so guard while the + // author is still typing. + if (!URL.canParse(src)) { + return ( +
+ + No image URL yet + +
+ ); + } + return ( -
- {fields.alt.value} - {fields.priority.value ? ( -
- Priority image -
- ) : null} -
+ ); }, schema: {