import { defineField, defineType } from "sanity"; import { Table } from "lucide-react"; export default defineType({ name: "tableBlock", title: "Table Block", type: "object", icon: Table, fields: [ defineField({ name: "rows", title: "Rows", type: "array", of: [ { type: "object", name: "tableRow", fields: [ defineField({ name: "cells", title: "Cells", type: "array", of: [{ type: "string" }], }), ], }, ], }), ], preview: { select: { rows: "rows", }, prepare({ rows }) { const count = rows?.length || 0; return { title: `Table (${count} rows)`, }; }, }, });