{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "blog-cards",
  "type": "registry:block",
  "title": "Blog, cards",
  "description": "A grid of article cards with image, category, title, excerpt and date, plus a link to all posts.",
  "categories": [
    "blog"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/badge.json",
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json"
  ],
  "files": [
    {
      "path": "src/blocks/blog-cards/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/blog-cards/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, media, t } from '../_shared/schema';\n\n// KB-178: a post may have no title (date, picture, text and link only); its link is then named by the excerpt, else the category or date.\nconst post = z.object({ category: t(30), title: t(100).optional(), excerpt: t(200), meta: t(60), href: t(300), media });\n\nconst schema = z.object({\n  /** Omit the section heading when the surrounding page already provides it. */\n  showHeader: z.boolean().optional(),\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  posts: z.array(post).min(1).max(6),\n  more: link,\n});\n\nexport const spec = defineSpec({\n  type: 'blog-cards',\n  aliases: ['blog/cards'],\n  name: 'Blog, cards',\n  category: 'blog',\n  role: 'body',\n  description: 'A grid of article cards with image, category, title, excerpt and date, plus a link to all posts.',\n  schema,\n  defaults: {\n    eyebrow: 'Name the topic',\n    title: 'Say what the posts are about',\n    description: 'Say in one line who writes the posts and what they offer.',\n    posts: [\n      { category: 'Category', title: 'Say what the post is about, as a title', excerpt: 'Say in one or two sentences what the reader gets from the post.', meta: '1 Jan 0000 · 0 min read', href: '#post-1', media: { src: '', alt: 'Show what the post is about, in one picture' } },\n      { category: 'Category', title: 'Say what the post is about', excerpt: 'Say in one or two sentences what the reader gets from the post.', meta: '1 Jan 0000 · 0 min read', href: '#post-2', media: { src: '', alt: 'Show what the post is about, in one picture' } },\n      { category: 'Category', title: 'Say what the post is about, as a title', excerpt: 'Say in one or two sentences what the reader gets from the post.', meta: '1 Jan 0000 · 0 min read', href: '#post-3', media: { src: '', alt: 'Show what the post is about, in one picture' } },\n    ],\n    more: { label: 'Second action', href: '#journal' },\n  },\n});\n"
    },
    {
      "path": "src/blocks/blog-cards/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/blog-cards/index.tsx",
      "content": "import { useContext, useId } from 'react';\nimport { HeadingLevelContext, Media, Text, withHeadingLevel } from '../../editing';\nimport { Badge } from '../../ui/badge';\nimport { safeHref } from '../../ui/button';\nimport { ActionLink, Container, Section, SectionHeader, useEditing } from '../_shared/kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\nfunction BlogCards({ props }: BlockProps<Props>) {\n  const id = useId();\n  const editing = useEditing();\n  const showHeader = props.showHeader !== false;\n  const CardHeading = useContext(HeadingLevelContext)?.level === '1' ? 'h2' : 'h3';\n  return (\n    <Section labelledBy={showHeader ? id : undefined}>\n      <Container>\n        {showHeader && <div className=\"flex flex-col justify-between gap-6 @3xl:flex-row @3xl:items-end\">\n          <SectionHeader id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n          <ActionLink path={['more']} value={props.more} variant=\"secondary\" size=\"md\" className=\"self-start @3xl:self-auto\" />\n        </div>}\n        <ul className={`${showHeader ? 'mt-14 ' : ''}grid gap-8 @2xl:grid-cols-2 @5xl:grid-cols-3`}>\n          {props.posts.map((p, i) => (\n            <li key={i}>\n              <article className=\"group relative flex h-full flex-col\">\n                <Media path={['posts', i, 'media']} value={p.media} ratio=\"16 / 10\" className=\"rounded-kh-lg border border-kh-line\" />\n                <div className=\"mt-5 flex items-center gap-3\">\n                  <Badge tone=\"accent\">\n                    <Text path={['posts', i, 'category']} value={p.category} as=\"span\" />\n                  </Badge>\n                  <Text path={['posts', i, 'meta']} value={p.meta} as=\"span\" className=\"text-kh-caption text-kh-muted\" />\n                </div>\n                {p.title || editing ? (\n                  <CardHeading className=\"mt-3 text-kh-heading font-semibold\">\n                    <a href={safeHref(p.href)} className=\"rounded-kh-sm after:absolute after:inset-0 after:content-[''] hover:underline hover:[text-decoration-color:var(--kh-edge)] hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)\">\n                      <Text path={['posts', i, 'title']} value={p.title ?? ''} as=\"span\" placeholder=\"Title\" />\n                    </a>\n                  </CardHeading>\n                ) : (\n                  <a href={safeHref(p.href)} aria-label={p.excerpt || p.category || p.meta || undefined} className=\"rounded-kh-sm after:absolute after:inset-0 after:content-[''] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)\" />\n                )}\n                <Text path={['posts', i, 'excerpt']} value={p.excerpt} as=\"p\" className=\"mt-2 text-kh-small text-kh-muted\" />\n              </article>\n            </li>\n          ))}\n        </ul>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(BlogCards);\n"
    }
  ]
}
