{
  "$schema": "https://registry.buildy.tw/schema/registry-item.json",
  "dependencies": [],
  "description": "Posts as a grid, a list or a magazine.",
  "devDependencies": [],
  "digest": "0.1.0",
  "files": [
    {
      "content": "// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.\n/**\n * A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first\n * post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news),\n * filter mode (none, topics), pager (none, pages), tone, density.\n */\nimport { Fragment, type ReactNode } from \"react\";\nimport { Block, Grid, Stack } from \"../compose\";\nimport { Pager } from \"../components/pager\";\nimport { PostCard } from \"../blocks/post-card\";\nimport { SectionFrame } from \"../components/section-frame\";\nimport { Switcher } from \"../components/switcher\";\nimport { SwitcherItem } from \"../components/switcher-item\";\nimport { fitCols, tpl, uniqLabel } from \"../utils\";\nimport type { PostTopic, PostFilter, PostPager } from \"./post-grid.types\";\nimport type { Post, PostLabels } from \"./post-card.types\";\nimport type { HeadLink } from \"../components/section-frame.types\";\n\nexport type PostGridProps = {\n  id: string;\n  title: string;\n  posts: Post[];\n  labels: PostLabels;\n  action?: HeadLink;\n  filter?: PostFilter;\n  pager?: PostPager;\n  layout?: \"grid\" | \"list\" | \"magazine\";\n  cols?: \"1-2\" | \"1-3\" | \"1-4\";\n  media?: \"image\" | \"none\";\n  meta?: \"full\" | \"short\" | \"news\";\n  tone?: \"default\" | \"muted\";\n  density?: \"default\" | \"compact\";\n  landmarkLabel?: string;\n  onTopic?: (value: string) => void;\n  onPage?: (page: number) => void;\n};\n\nexport function PostGrid({\n  id,\n  title,\n  posts,\n  labels,\n  action,\n  filter,\n  pager,\n  layout = \"grid\",\n  cols = \"1-3\",\n  media = \"image\",\n  meta = \"full\",\n  tone = \"default\",\n  density = \"default\",\n  landmarkLabel,\n  onTopic,\n  onPage,\n}: PostGridProps) {\n  return (\n    <SectionFrame\n      id={id}\n      title={title}\n      action={action}\n      tone={tone}\n      density={(((density as string) === \"compact\") ? \"compact\" : \"default\")}\n      measure={(((meta as string) === \"news\") ? \"fill\" : \"default\")}\n      className={(((meta as string) === \"news\") ? \"py-0\" : \"\")}\n      landmarkLabel={landmarkLabel}\n    >\n      {(filter?.mode === \"topics\") ? (\n        <Switcher label={filter?.label}>\n          {(filter?.topics ?? []).map((tab) => (\n            <SwitcherItem key={tab.id} active={(tab.value === filter?.topic)} onClick={() => onTopic?.(tab.value)}>\n              {tab.title}\n            </SwitcherItem>\n          ))}\n        </Switcher>\n      ) : null}\n      {((posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic)?.length ?? 0) > 0) ? (\n        <>\n          {((layout as string) === \"magazine\") ? (\n            <Stack gap=\"6\" align=\"stretch\" data-slot=\"items\">\n              {(posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic) ?? []).map((p, i) => (\n                <Fragment key={p.id}>\n                  {(i === 0) ? (\n                    <PostCard post={p} labels={labels} layout=\"horizontal\" media={media} meta={meta} density={density} />\n                  ) : null}\n                </Fragment>\n              ))}\n              <Grid cols={cols} className=\"gap-6\">\n                {(posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic) ?? []).map((p, i) => (\n                  <Fragment key={p.id}>\n                    {(i > 0) ? (\n                      <PostCard post={p} labels={labels} media={media} meta={meta} density={density} />\n                    ) : null}\n                  </Fragment>\n                ))}\n              </Grid>\n            </Stack>\n          ) : (\n            <Grid\n              cols={\n                (layout as string) === \"list\" ? \"1\"\n                : fitCols(cols, (posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic)?.length ?? 0))\n              }\n              className=\"w-full gap-6\"\n              data-slot=\"items\"\n            >\n              {(posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic) ?? []).map((p) => (\n                <PostCard key={p.id}\n                  post={p}\n                  labels={labels}\n                  layout={(((layout as string) === \"list\") ? \"horizontal\" : \"vertical\")}\n                  media={media}\n                  meta={meta}\n                  density={density}\n                />\n              ))}\n            </Grid>\n          )}\n        </>\n      ) : null}\n      {((pager?.mode === \"pages\") && ((posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic)?.length ?? 0) > 0)) ? (\n        <Block\n          tag=\"nav\"\n          aria-label={\n            landmarkLabel ? uniqLabel(tpl(\"{0}, {1}\", pager?.label, landmarkLabel))\n            : pager?.label\n          }\n          data-slot=\"posts-pager\"\n        >\n          <Pager\n            page={(pager?.page ?? 1)}\n            pages={(pager?.pages ?? 1)}\n            summary={tpl(pager?.summary, (pager?.page ?? 1), (pager?.pages ?? 1))}\n            previousLabel={(pager?.previous ?? \"\")}\n            nextLabel={(pager?.next ?? \"\")}\n            numbered={true}\n            pageLabel={pager?.pageLabel}\n            pageUrl={pager?.url}\n            firstUrl={pager?.firstUrl}\n            onPage={(arg: number) => onPage?.(arg)}\n          />\n        </Block>\n      ) : null}\n    </SectionFrame>\n  );\n}\n",
      "path": "blocks/post-grid.tsx",
      "target": "blocks/post-grid.tsx"
    },
    {
      "content": "// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.\n\nexport type PostTopic = {\n  id: string;\n  title: string;\n  value: string;\n};\n\nexport type PostFilter = {\n  /** topics: tabs above the posts; the page filters by `topic` */\n  mode?: \"none\" | \"topics\";\n  /** the topic tabs */\n  topics?: PostTopic[];\n  /** accessible name of the topic tabs */\n  label?: string;\n  /** the value of the chosen topic; empty: all posts */\n  topic?: string;\n};\n\nexport type PostPager = {\n  /** pages: a numbered Pager under the posts, in a nav landmark */\n  mode?: \"none\" | \"pages\";\n  /** the current page, from 1 */\n  page?: number;\n  /** the number of pages */\n  pages?: number;\n  /** accessible name of the pager nav (Pages of posts) */\n  label?: string;\n  /** template of the summary line: ｛0｝ the page, ｛1｝ the pages */\n  summary?: string;\n  /** accessible name of the previous-page button */\n  previous?: string;\n  /** accessible name of the next-page button */\n  next?: string;\n  /** template of the accessible name of a page button, ｛0｝ the number */\n  pageLabel?: string;\n  /** address of page ｛0｝ (filled by the adapter): with it the pages are links; none: buttons that emit page */\n  url?: string;\n  /** address of page 1 when it is not url with 1 (the list's own address) */\n  firstUrl?: string;\n};\n",
      "path": "blocks/post-grid.types.ts",
      "target": "blocks/post-grid.types.ts"
    }
  ],
  "meta": {
    "category": "content",
    "group": "blog",
    "kind": "block",
    "tags": [
      "react",
      "block"
    ]
  },
  "name": "post-grid",
  "registryDependencies": [
    "compose",
    "pager",
    "post-card",
    "section-frame",
    "switcher",
    "switcher-item",
    "utils"
  ],
  "runtime": "react",
  "title": "Post Grid",
  "type": "registry:block"
}
