{
  "$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-->\n<script lang=\"ts\" module>\n  import type { Snippet } from \"svelte\";\n  import type { PostTopic, PostFilter, PostPager } from \"./post-grid.types\";\n  import type { Post, PostLabels } from \"./post-card.types\";\n  import type { HeadLink } from \"../components/section-frame.types\";\n\n  export 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</script>\n\n<script lang=\"ts\">\n  import Block from \"../compose/Block.svelte\";\n  import Grid from \"../compose/Grid.svelte\";\n  import Stack from \"../compose/Stack.svelte\";\n  import Pager from \"../components/pager.svelte\";\n  import PostCard from \"../blocks/post-card.svelte\";\n  import SectionFrame from \"../components/section-frame.svelte\";\n  import Switcher from \"../components/switcher.svelte\";\n  import SwitcherItem from \"../components/switcher-item.svelte\";\n  import { fitCols, tpl, uniqLabel } from \"../utils\";\n\n  let {\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 = $props();\n</script>\n\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  class={(((meta as string) === \"news\") ? \"py-0\" : \"\")}\n  landmarkLabel={landmarkLabel}\n>\n  {#if (filter?.mode === \"topics\")}\n    <Switcher label={filter?.label}>\n      {#each filter?.topics as tab (tab.id)}\n        <SwitcherItem active={(tab.value === filter?.topic)} onclick={() => ontopic?.(tab.value)}>\n          {tab.title}\n        </SwitcherItem>\n      {/each}\n    </Switcher>\n  {/if}\n  {#if ((posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic)?.length ?? 0) > 0)}\n    {#if ((layout as string) === \"magazine\")}\n      <Stack gap=\"6\" align=\"stretch\" data-slot=\"items\">\n        {#each posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic) as p, i (p.id)}\n          {#if (i === 0)}\n            <PostCard post={p} labels={labels} layout=\"horizontal\" media={media} meta={meta} density={density} />\n          {/if}\n        {/each}\n        <Grid cols={cols} class=\"gap-6\">\n          {#each posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic) as p, i (p.id)}\n            {#if (i > 0)}\n              <PostCard post={p} labels={labels} media={media} meta={meta} density={density} />\n            {/if}\n          {/each}\n        </Grid>\n      </Stack>\n    {:else}\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        class=\"w-full gap-6\"\n        data-slot=\"items\"\n      >\n        {#each posts.filter((i) => !filter?.topic || i[\"category\"] === filter?.topic) as p (p.id)}\n          <PostCard\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        {/each}\n      </Grid>\n    {/if}\n  {/if}\n  {#if ((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  {/if}\n</SectionFrame>\n",
      "path": "blocks/post-grid.svelte",
      "target": "blocks/post-grid.svelte"
    },
    {
      "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": [
      "svelte",
      "block"
    ]
  },
  "name": "post-grid",
  "registryDependencies": [
    "block",
    "grid",
    "pager",
    "post-card",
    "section-frame",
    "stack",
    "switcher",
    "switcher-item",
    "utils"
  ],
  "runtime": "svelte",
  "title": "Post Grid",
  "type": "registry:block"
}
