/** * SEO OG Image field for the content editor. * * Renders an image picker (reusing MediaPickerModal) that stores the * selected image URL in `seo.image`. Designed to sit next to the * Featured Image field in a two-column grid. */ import { Button, Label } from "@cloudflare/kumo"; import { useLingui } from "@lingui/react/macro"; import { Image as ImageIcon, X } from "@phosphor-icons/react"; import * as React from "react"; import type { ContentSeo, ContentSeoInput, MediaItem } from "../lib/api"; import { MediaPickerModal } from "./MediaPickerModal"; export interface SeoImageFieldProps { seo?: ContentSeo; onChange: (seo: ContentSeoInput) => void; } export function SeoImageField({ seo, onChange }: SeoImageFieldProps) { const { t } = useLingui(); const [pickerOpen, setPickerOpen] = React.useState(false); const imageUrl = seo?.image || null; const handleSelect = (item: MediaItem) => { const isLocalProvider = !item.provider || item.provider === "local"; const url = isLocalProvider ? `/_emdash/api/media/file/${item.storageKey || item.id}` : item.url; onChange({ image: url }); }; const handleRemove = () => { onChange({ image: null }); }; return (
{imageUrl ? (
) : ( )}

{t`Image shown when this page is shared on social media`}

); }