Post Grid
Posts as a grid, a list or a magazine.
Install
npx ui8kit add post-gridPulls in: block, compose, grid, kit-box, pager, post-card, section-frame, stack, switcher, switcher-item, utils
Preview
Latest News
All PostsWhy static-first pages still win
Less script, less waiting, and pages that keep working offline.
By
Mar 18, 2026
6 min read
Design tokens without the drift
How one list of tokens feeds every runtime and every theme.
By
Mar 11, 2026
5 min read
Launch notes for spring
New blocks, faster builds and a calmer dashboard.
By
Mar 04, 2026
3 min read
Shipping with a small team
A short checklist that keeps a team of four on track.
By
Feb 25, 2026
4 min read
Accessible forms in an afternoon
Labels, errors and focus: the three things that matter most.
By
Feb 14, 2026
7 min read
What a good pricing page shows
Plans, limits and answers, in that order.
By
Feb 02, 2026
5 min read
Code
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdnnpx ui8kit add post-grid<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first
post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news),
filter mode (none, topics), pager (none, pages), tone, density.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { PostTopic, PostFilter, PostPager } from "./post-grid.types";
import type { Post, PostLabels } from "./post-card.types";
import type { HeadLink } from "../components/section-frame.types";
export type PostGridProps = {
id: string;
title: string;
posts: Post[];
labels: PostLabels;
action?: HeadLink;
filter?: PostFilter;
pager?: PostPager;
layout?: "grid" | "list" | "magazine";
cols?: "1-2" | "1-3" | "1-4";
media?: "image" | "none";
meta?: "full" | "short" | "news";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
ontopic?: (value: string) => void;
onpage?: (page: number) => void;
};
</script>
<script lang="ts">
import Block from "../compose/Block.svelte";
import Grid from "../compose/Grid.svelte";
import Stack from "../compose/Stack.svelte";
import Pager from "../components/pager.svelte";
import PostCard from "../blocks/post-card.svelte";
import SectionFrame from "../components/section-frame.svelte";
import Switcher from "../components/switcher.svelte";
import SwitcherItem from "../components/switcher-item.svelte";
import { fitCols, tpl, uniqLabel } from "../utils";
let {
id,
title,
posts,
labels,
action,
filter,
pager,
layout = "grid",
cols = "1-3",
media = "image",
meta = "full",
tone = "default",
density = "default",
landmarkLabel,
ontopic,
onpage,
}: PostGridProps = $props();
</script>
<SectionFrame
id={id}
title={title}
action={action}
tone={tone}
density={(((density as string) === "compact") ? "compact" : "default")}
measure={(((meta as string) === "news") ? "fill" : "default")}
class={(((meta as string) === "news") ? "py-0" : "")}
landmarkLabel={landmarkLabel}
>
{#if (filter?.mode === "topics")}
<Switcher label={filter?.label}>
{#each filter?.topics as tab (tab.id)}
<SwitcherItem active={(tab.value === filter?.topic)} onclick={() => ontopic?.(tab.value)}>
{tab.title}
</SwitcherItem>
{/each}
</Switcher>
{/if}
{#if ((posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0) > 0)}
{#if ((layout as string) === "magazine")}
<Stack gap="6" align="stretch" data-slot="items">
{#each posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) as p, i (p.id)}
{#if (i === 0)}
<PostCard post={p} labels={labels} layout="horizontal" media={media} meta={meta} density={density} />
{/if}
{/each}
<Grid cols={cols} class="gap-6">
{#each posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) as p, i (p.id)}
{#if (i > 0)}
<PostCard post={p} labels={labels} media={media} meta={meta} density={density} />
{/if}
{/each}
</Grid>
</Stack>
{:else}
<Grid
cols={
(layout as string) === "list" ? "1"
: fitCols(cols, (posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0))
}
class="w-full gap-6"
data-slot="items"
>
{#each posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) as p (p.id)}
<PostCard
post={p}
labels={labels}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
media={media}
meta={meta}
density={density}
/>
{/each}
</Grid>
{/if}
{/if}
{#if ((pager?.mode === "pages") && ((posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0) > 0))}
<Block
tag="nav"
aria-label={
landmarkLabel ? uniqLabel(tpl("{0}, {1}", pager?.label, landmarkLabel))
: pager?.label
}
data-slot="posts-pager"
>
<Pager
page={(pager?.page ?? 1)}
pages={(pager?.pages ?? 1)}
summary={tpl(pager?.summary, (pager?.page ?? 1), (pager?.pages ?? 1))}
previousLabel={(pager?.previous ?? "")}
nextLabel={(pager?.next ?? "")}
numbered={true}
pageLabel={pager?.pageLabel}
pageUrl={pager?.url}
firstUrl={pager?.firstUrl}
onpage={(arg: number) => onpage?.(arg)}
/>
</Block>
{/if}
</SectionFrame>
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type PostTopic = {
id: string;
title: string;
value: string;
};
export type PostFilter = {
/** topics: tabs above the posts; the page filters by `topic` */
mode?: "none" | "topics";
/** the topic tabs */
topics?: PostTopic[];
/** accessible name of the topic tabs */
label?: string;
/** the value of the chosen topic; empty: all posts */
topic?: string;
};
export type PostPager = {
/** pages: a numbered Pager under the posts, in a nav landmark */
mode?: "none" | "pages";
/** the current page, from 1 */
page?: number;
/** the number of pages */
pages?: number;
/** accessible name of the pager nav (Pages of posts) */
label?: string;
/** template of the summary line: {0} the page, {1} the pages */
summary?: string;
/** accessible name of the previous-page button */
previous?: string;
/** accessible name of the next-page button */
next?: string;
/** template of the accessible name of a page button, {0} the number */
pageLabel?: string;
/** address of page {0} (filled by the adapter): with it the pages are links; none: buttons that emit page */
url?: string;
/** address of page 1 when it is not url with 1 (the list's own address) */
firstUrl?: string;
};
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdnnpx ui8kit add post-grid// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first
* post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news),
* filter mode (none, topics), pager (none, pages), tone, density.
*/
import { Fragment, type ReactNode } from "react";
import { Block, Grid, Stack } from "../compose";
import { Pager } from "../components/pager";
import { PostCard } from "../blocks/post-card";
import { SectionFrame } from "../components/section-frame";
import { Switcher } from "../components/switcher";
import { SwitcherItem } from "../components/switcher-item";
import { fitCols, tpl, uniqLabel } from "../utils";
import type { PostTopic, PostFilter, PostPager } from "./post-grid.types";
import type { Post, PostLabels } from "./post-card.types";
import type { HeadLink } from "../components/section-frame.types";
export type PostGridProps = {
id: string;
title: string;
posts: Post[];
labels: PostLabels;
action?: HeadLink;
filter?: PostFilter;
pager?: PostPager;
layout?: "grid" | "list" | "magazine";
cols?: "1-2" | "1-3" | "1-4";
media?: "image" | "none";
meta?: "full" | "short" | "news";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
onTopic?: (value: string) => void;
onPage?: (page: number) => void;
};
export function PostGrid({
id,
title,
posts,
labels,
action,
filter,
pager,
layout = "grid",
cols = "1-3",
media = "image",
meta = "full",
tone = "default",
density = "default",
landmarkLabel,
onTopic,
onPage,
}: PostGridProps) {
return (
<SectionFrame
id={id}
title={title}
action={action}
tone={tone}
density={(((density as string) === "compact") ? "compact" : "default")}
measure={(((meta as string) === "news") ? "fill" : "default")}
className={(((meta as string) === "news") ? "py-0" : "")}
landmarkLabel={landmarkLabel}
>
{(filter?.mode === "topics") ? (
<Switcher label={filter?.label}>
{(filter?.topics ?? []).map((tab) => (
<SwitcherItem key={tab.id} active={(tab.value === filter?.topic)} onClick={() => onTopic?.(tab.value)}>
{tab.title}
</SwitcherItem>
))}
</Switcher>
) : null}
{((posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0) > 0) ? (
<>
{((layout as string) === "magazine") ? (
<Stack gap="6" align="stretch" data-slot="items">
{(posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) ?? []).map((p, i) => (
<Fragment key={p.id}>
{(i === 0) ? (
<PostCard post={p} labels={labels} layout="horizontal" media={media} meta={meta} density={density} />
) : null}
</Fragment>
))}
<Grid cols={cols} className="gap-6">
{(posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) ?? []).map((p, i) => (
<Fragment key={p.id}>
{(i > 0) ? (
<PostCard post={p} labels={labels} media={media} meta={meta} density={density} />
) : null}
</Fragment>
))}
</Grid>
</Stack>
) : (
<Grid
cols={
(layout as string) === "list" ? "1"
: fitCols(cols, (posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0))
}
className="w-full gap-6"
data-slot="items"
>
{(posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) ?? []).map((p) => (
<PostCard key={p.id}
post={p}
labels={labels}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
media={media}
meta={meta}
density={density}
/>
))}
</Grid>
)}
</>
) : null}
{((pager?.mode === "pages") && ((posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0) > 0)) ? (
<Block
tag="nav"
aria-label={
landmarkLabel ? uniqLabel(tpl("{0}, {1}", pager?.label, landmarkLabel))
: pager?.label
}
data-slot="posts-pager"
>
<Pager
page={(pager?.page ?? 1)}
pages={(pager?.pages ?? 1)}
summary={tpl(pager?.summary, (pager?.page ?? 1), (pager?.pages ?? 1))}
previousLabel={(pager?.previous ?? "")}
nextLabel={(pager?.next ?? "")}
numbered={true}
pageLabel={pager?.pageLabel}
pageUrl={pager?.url}
firstUrl={pager?.firstUrl}
onPage={(arg: number) => onPage?.(arg)}
/>
</Block>
) : null}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type PostTopic = {
id: string;
title: string;
value: string;
};
export type PostFilter = {
/** topics: tabs above the posts; the page filters by `topic` */
mode?: "none" | "topics";
/** the topic tabs */
topics?: PostTopic[];
/** accessible name of the topic tabs */
label?: string;
/** the value of the chosen topic; empty: all posts */
topic?: string;
};
export type PostPager = {
/** pages: a numbered Pager under the posts, in a nav landmark */
mode?: "none" | "pages";
/** the current page, from 1 */
page?: number;
/** the number of pages */
pages?: number;
/** accessible name of the pager nav (Pages of posts) */
label?: string;
/** template of the summary line: {0} the page, {1} the pages */
summary?: string;
/** accessible name of the previous-page button */
previous?: string;
/** accessible name of the next-page button */
next?: string;
/** template of the accessible name of a page button, {0} the number */
pageLabel?: string;
/** address of page {0} (filled by the adapter): with it the pages are links; none: buttons that emit page */
url?: string;
/** address of page 1 when it is not url with 1 (the list's own address) */
firstUrl?: string;
};
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdnnpx ui8kit add post-grid// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type PostTopic = {
id: string;
title: string;
value: string;
};
export type PostFilter = {
/** topics: tabs above the posts; the page filters by `topic` */
mode?: "none" | "topics";
/** the topic tabs */
topics?: PostTopic[];
/** accessible name of the topic tabs */
label?: string;
/** the value of the chosen topic; empty: all posts */
topic?: string;
};
export type PostPager = {
/** pages: a numbered Pager under the posts, in a nav landmark */
mode?: "none" | "pages";
/** the current page, from 1 */
page?: number;
/** the number of pages */
pages?: number;
/** accessible name of the pager nav (Pages of posts) */
label?: string;
/** template of the summary line: {0} the page, {1} the pages */
summary?: string;
/** accessible name of the previous-page button */
previous?: string;
/** accessible name of the next-page button */
next?: string;
/** template of the accessible name of a page button, {0} the number */
pageLabel?: string;
/** address of page {0} (filled by the adapter): with it the pages are links; none: buttons that emit page */
url?: string;
/** address of page 1 when it is not url with 1 (the list's own address) */
firstUrl?: string;
};
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first
post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news),
filter mode (none, topics), pager (none, pages), tone, density.
-->
<script lang="ts">
import type { PostTopic, PostFilter, PostPager } from "./post-grid.types";
import type { Post, PostLabels } from "./post-card.types";
import type { HeadLink } from "../components/section-frame.types";
export type PostGridProps = {
id: string;
title: string;
posts: Post[];
labels: PostLabels;
action?: HeadLink;
filter?: PostFilter;
pager?: PostPager;
layout?: "grid" | "list" | "magazine";
cols?: "1-2" | "1-3" | "1-4";
media?: "image" | "none";
meta?: "full" | "short" | "news";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Block from "../compose/Block.vue";
import Grid from "../compose/Grid.vue";
import Stack from "../compose/Stack.vue";
import Pager from "../components/pager.vue";
import PostCard from "../blocks/post-card.vue";
import SectionFrame from "../components/section-frame.vue";
import Switcher from "../components/switcher.vue";
import SwitcherItem from "../components/switcher-item.vue";
import { fitCols, tpl, uniqLabel } from "../utils";
const {
id,
title,
posts,
labels,
action,
filter,
pager,
layout = "grid",
cols = "1-3",
media = "image",
meta = "full",
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<PostGridProps>();
const emit = defineEmits<{ topic: [value: string], page: [page: number] }>();
</script>
<template>
<SectionFrame
:id="id"
:title="title"
:action="action"
:tone="tone"
:density="(((density as string) === 'compact') ? 'compact' : 'default')"
:measure="(((meta as string) === 'news') ? 'fill' : 'default')"
:class="(((meta as string) === 'news') ? 'py-0' : '')"
:landmarkLabel="landmarkLabel"
>
<Switcher v-if="(filter?.mode === 'topics')" :label="filter?.label">
<SwitcherItem
v-for="tab in filter?.topics"
:key="tab.id"
:active="(tab.value === filter?.topic)"
@click="() => emit('topic', tab.value)"
>
{{ tab.title }}
</SwitcherItem>
</Switcher>
<template v-if="((posts.filter((i) => !filter?.topic || i['category'] === filter?.topic)?.length ?? 0) > 0)">
<Stack v-if="((layout as string) === 'magazine')" gap="6" align="stretch" data-slot="items">
<template v-for="(p, i) in posts.filter((i) => !filter?.topic || i['category'] === filter?.topic)" :key="p.id">
<PostCard
v-if="(i === 0)"
:post="p"
:labels="labels"
layout="horizontal"
:media="media"
:meta="meta"
:density="density"
/>
</template>
<Grid :cols="cols" class="gap-6">
<template v-for="(p, i) in posts.filter((i) => !filter?.topic || i['category'] === filter?.topic)" :key="p.id">
<PostCard v-if="(i > 0)" :post="p" :labels="labels" :media="media" :meta="meta" :density="density" />
</template>
</Grid>
</Stack>
<Grid v-else
:cols="
(layout as string) === 'list' ? '1'
: fitCols(cols, (posts.filter((i) => !filter?.topic || i['category'] === filter?.topic)?.length ?? 0))
"
class="w-full gap-6"
data-slot="items"
>
<PostCard v-for="p in posts.filter((i) => !filter?.topic || i['category'] === filter?.topic)" :key="p.id"
:post="p"
:labels="labels"
:layout="(((layout as string) === 'list') ? 'horizontal' : 'vertical')"
:media="media"
:meta="meta"
:density="density"
/>
</Grid>
</template>
<Block v-if="((pager?.mode === 'pages') && ((posts.filter((i) => !filter?.topic || i['category'] === filter?.topic)?.length ?? 0) > 0))"
tag="nav"
:aria-label="
landmarkLabel ? uniqLabel(tpl('{0}, {1}', pager?.label, landmarkLabel))
: pager?.label
"
data-slot="posts-pager"
>
<Pager
:page="(pager?.page ?? 1)"
:pages="(pager?.pages ?? 1)"
:summary="tpl(pager?.summary, (pager?.page ?? 1), (pager?.pages ?? 1))"
:previousLabel="(pager?.previous ?? '')"
:nextLabel="(pager?.next ?? '')"
:numbered="true"
:pageLabel="pager?.pageLabel"
:pageUrl="pager?.url"
:firstUrl="pager?.firstUrl"
@page="(arg: number) => emit('page', arg)"
/>
</Block>
</SectionFrame>
</template>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdnnpx ui8kit add post-grid// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first
* post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news),
* filter mode (none, topics), pager (none, pages), tone, density.
*/
import { For, type JSX } from "solid-js";
import { Block, Grid, Stack } from "../compose";
import { Pager } from "../components/pager";
import { PostCard } from "../blocks/post-card";
import { SectionFrame } from "../components/section-frame";
import { Switcher } from "../components/switcher";
import { SwitcherItem } from "../components/switcher-item";
import { fitCols, tpl, uniqLabel } from "../utils";
import type { PostTopic, PostFilter, PostPager } from "./post-grid.types";
import type { Post, PostLabels } from "./post-card.types";
import type { HeadLink } from "../components/section-frame.types";
export type PostGridProps = {
id: string;
title: string;
posts: Post[];
labels: PostLabels;
action?: HeadLink;
filter?: PostFilter;
pager?: PostPager;
layout?: "grid" | "list" | "magazine";
cols?: "1-2" | "1-3" | "1-4";
media?: "image" | "none";
meta?: "full" | "short" | "news";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
onTopic?: (value: string) => void;
onPage?: (page: number) => void;
};
export function PostGrid({
id,
title,
posts,
labels,
action,
filter,
pager,
layout = "grid",
cols = "1-3",
media = "image",
meta = "full",
tone = "default",
density = "default",
landmarkLabel,
onTopic,
onPage,
}: PostGridProps) {
return (
<SectionFrame
id={id}
title={title}
action={action}
tone={tone}
density={(((density as string) === "compact") ? "compact" : "default")}
measure={(((meta as string) === "news") ? "fill" : "default")}
class={(((meta as string) === "news") ? "py-0" : "")}
landmarkLabel={landmarkLabel}
>
{(filter?.mode === "topics") ? (
<Switcher label={filter?.label}>
<For each={filter?.topics ?? []}>{(tab) => (
<SwitcherItem active={(tab.value === filter?.topic)} onClick={() => onTopic?.(tab.value)}>
{tab.title}
</SwitcherItem>
)}</For>
</Switcher>
) : null}
{((posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0) > 0) ? (
<>
{((layout as string) === "magazine") ? (
<Stack gap="6" align="stretch" data-slot="items">
<For each={posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) ?? []}>{(p, iOf) => { const i = iOf(); return (
<>
{(i === 0) ? (
<PostCard post={p} labels={labels} layout="horizontal" media={media} meta={meta} density={density} />
) : null}
</>
); }}</For>
<Grid cols={cols} class="gap-6">
<For each={posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) ?? []}>{(p, iOf) => { const i = iOf(); return (
<>
{(i > 0) ? (
<PostCard post={p} labels={labels} media={media} meta={meta} density={density} />
) : null}
</>
); }}</For>
</Grid>
</Stack>
) : (
<Grid
cols={
(layout as string) === "list" ? "1"
: fitCols(cols, (posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0))
}
class="w-full gap-6"
data-slot="items"
>
<For each={posts.filter((i) => !filter?.topic || i["category"] === filter?.topic) ?? []}>{(p) => (
<PostCard
post={p}
labels={labels}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
media={media}
meta={meta}
density={density}
/>
)}</For>
</Grid>
)}
</>
) : null}
{((pager?.mode === "pages") && ((posts.filter((i) => !filter?.topic || i["category"] === filter?.topic)?.length ?? 0) > 0)) ? (
<Block
tag="nav"
aria-label={
landmarkLabel ? uniqLabel(tpl("{0}, {1}", pager?.label, landmarkLabel))
: pager?.label
}
data-slot="posts-pager"
>
<Pager
page={(pager?.page ?? 1)}
pages={(pager?.pages ?? 1)}
summary={tpl(pager?.summary, (pager?.page ?? 1), (pager?.pages ?? 1))}
previousLabel={(pager?.previous ?? "")}
nextLabel={(pager?.next ?? "")}
numbered={true}
pageLabel={pager?.pageLabel}
pageUrl={pager?.url}
firstUrl={pager?.firstUrl}
onPage={(arg: number) => onPage?.(arg)}
/>
</Block>
) : null}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type PostTopic = {
id: string;
title: string;
value: string;
};
export type PostFilter = {
/** topics: tabs above the posts; the page filters by `topic` */
mode?: "none" | "topics";
/** the topic tabs */
topics?: PostTopic[];
/** accessible name of the topic tabs */
label?: string;
/** the value of the chosen topic; empty: all posts */
topic?: string;
};
export type PostPager = {
/** pages: a numbered Pager under the posts, in a nav landmark */
mode?: "none" | "pages";
/** the current page, from 1 */
page?: number;
/** the number of pages */
pages?: number;
/** accessible name of the pager nav (Pages of posts) */
label?: string;
/** template of the summary line: {0} the page, {1} the pages */
summary?: string;
/** accessible name of the previous-page button */
previous?: string;
/** accessible name of the next-page button */
next?: string;
/** template of the accessible name of a page button, {0} the number */
pageLabel?: string;
/** address of page {0} (filled by the adapter): with it the pages are links; none: buttons that emit page */
url?: string;
/** address of page 1 when it is not url with 1 (the list's own address) */
firstUrl?: string;
};
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdnnpx ui8kit add post-grid// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/organisms/post-grid.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/compose"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// PostGridProps are the props of PostGrid; the values are the JSON shapes of the TypeScript props.
type PostGridProps struct {
Id any `json:"id"`
Title any `json:"title"`
Posts any `json:"posts"`
Labels any `json:"labels"`
Action any `json:"action"`
Filter any `json:"filter"`
Pager any `json:"pager"`
Layout any `json:"layout"`
Cols any `json:"cols"`
Media any `json:"media"`
Meta any `json:"meta"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news), filter mode (none, topics), pager (none, pages), tone, density.
templ PostGrid(p PostGridProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vPosts := p.Posts }}
{{ vLabels := p.Labels }}
{{ vAction := p.Action }}
{{ vFilter := p.Filter }}
{{ vPager := p.Pager }}
{{ vLayout := uiutils.Def(p.Layout, "grid") }}
{{ vCols := uiutils.Def(p.Cols, "1-3") }}
{{ vMedia := uiutils.Def(p.Media, "image") }}
{{ vMeta := uiutils.Def(p.Meta, "full") }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vDensity := uiutils.Def(p.Density, "default") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Action: vAction, Tone: vTone, Density: uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "compact", "default"), Measure: uiutils.Cond(uiutils.T(uiutils.Eq(vMeta, "news")), "fill", "default"), Class: uiutils.Cnv(uiutils.Cond(uiutils.T(uiutils.Eq(vMeta, "news")), "py-0", "")), LandmarkLabel: vLandmarkLabel}) {
if uiutils.Eq(uiutils.Get(vFilter, "mode"), "topics") {
@Switcher(SwitcherProps{Label: uiutils.Get(vFilter, "label")}) {
for _, vTab := range uiutils.L(uiutils.Get(vFilter, "topics")) {
@SwitcherItem(SwitcherItemProps{Active: uiutils.Eq(uiutils.Get(vTab, "value"), uiutils.Get(vFilter, "topic"))}) {
{ uiutils.Text(uiutils.Get(vTab, "title")) }
}
}
}
}
if uiutils.Gt(uiutils.Len(uiutils.Where(vPosts, "category", uiutils.Get(vFilter, "topic"))), float64(0)) {
if uiutils.Eq(vLayout, "magazine") {
@compose.Stack(compose.StackProps{Gap: "6", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "items")}}) {
for vI, vP := range uiutils.L(uiutils.Where(vPosts, "category", uiutils.Get(vFilter, "topic"))) {
if uiutils.Eq(float64(vI), float64(0)) {
@PostCard(PostCardProps{Post: vP, Labels: vLabels, Layout: "horizontal", Media: vMedia, Meta: vMeta, Density: vDensity})
}
}
@compose.Grid(compose.GridProps{Cols: uiutils.S(vCols), BoxProps: box.BoxProps{Class: "gap-6"}}) {
for vI, vP := range uiutils.L(uiutils.Where(vPosts, "category", uiutils.Get(vFilter, "topic"))) {
if uiutils.Gt(float64(vI), float64(0)) {
@PostCard(PostCardProps{Post: vP, Labels: vLabels, Media: vMedia, Meta: vMeta, Density: vDensity})
}
}
}
}
} else {
@compose.Grid(compose.GridProps{Cols: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "list")), "1", uiutils.FitCols(vCols, uiutils.Len(uiutils.Where(vPosts, "category", uiutils.Get(vFilter, "topic")))))), BoxProps: box.BoxProps{Class: "w-full gap-6", Attrs: uiutils.Attrs("data-slot", "items")}}) {
for _, vP := range uiutils.L(uiutils.Where(vPosts, "category", uiutils.Get(vFilter, "topic"))) {
@PostCard(PostCardProps{Post: vP, Labels: vLabels, Layout: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "list")), "horizontal", "vertical"), Media: vMedia, Meta: vMeta, Density: vDensity})
}
}
}
}
if uiutils.T(uiutils.And(uiutils.Eq(uiutils.Get(vPager, "mode"), "pages"), uiutils.Gt(uiutils.Len(uiutils.Where(vPosts, "category", uiutils.Get(vFilter, "topic"))), float64(0)))) {
@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "nav", Attrs: uiutils.Attrs("aria-label", uiutils.Cond(uiutils.T(vLandmarkLabel), uiutils.Uniq(uiutils.Tpl("{0}, {1}", uiutils.Get(vPager, "label"), vLandmarkLabel)), uiutils.Get(vPager, "label")), "data-slot", "posts-pager")}}) {
@Pager(PagerProps{Page: uiutils.Coalesce(uiutils.Get(vPager, "page"), float64(1)), Pages: uiutils.Coalesce(uiutils.Get(vPager, "pages"), float64(1)), Summary: uiutils.Tpl(uiutils.Get(vPager, "summary"), uiutils.Coalesce(uiutils.Get(vPager, "page"), float64(1)), uiutils.Coalesce(uiutils.Get(vPager, "pages"), float64(1))), PreviousLabel: uiutils.Coalesce(uiutils.Get(vPager, "previous"), ""), NextLabel: uiutils.Coalesce(uiutils.Get(vPager, "next"), ""), Numbered: true, PageLabel: uiutils.Get(vPager, "pageLabel"), PageUrl: uiutils.Get(vPager, "url"), FirstUrl: uiutils.Get(vPager, "firstUrl")})
}
}
}
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdnnpx ui8kit add post-grid{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/post-grid.json
A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news), filter mode (none, topics), pager (none, pages), tone, density.
Props (p): id, title, posts, labels, action, filter, pager, layout, cols, media, meta, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_posts = (p.posts ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_action = (p.action ?? null) -%}
{%- set v_filter = (p.filter ?? null) -%}
{%- set v_pager = (p.pager ?? null) -%}
{%- set v_layout = (p.layout ?? 'grid') -%}
{%- set v_cols = (p.cols ?? '1-3') -%}
{%- set v_media = (p.media ?? 'image') -%}
{%- set v_meta = (p.meta ?? 'full') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_7 -%}
{%- if og_t(og_eq(og_get(v_filter, ['mode']), 'topics')) %}
{%- set c_2 -%}
{%- for v_tab in og_l(og_get(v_filter, ['topics'])) %}
{%- set c_1 -%}
{{ og_text(og_get(v_tab, ['title'])) }}
{%- endset -%}
{{ include('blocks/switcher-item.html.twig', {'p': {'active': og_eq(og_get(v_tab, ['value']), og_get(v_filter, ['topic']))}, 'children': og_markup(c_1)}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('blocks/switcher.html.twig', {'p': {'label': og_get(v_filter, ['label'])}, 'children': og_markup(c_2)}, with_context = false) }}
{%- endif %}
{%- if og_t(og_gt(og_len(og_where(v_posts, 'category', og_get(v_filter, ['topic']))), 0)) %}
{%- if og_t(og_eq(v_layout, 'magazine')) %}
{%- set c_4 -%}
{%- for v_p in og_l(og_where(v_posts, 'category', og_get(v_filter, ['topic']))) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_eq(v_i, 0)) %}
{{ include('blocks/post-card.html.twig', {'p': {'post': v_p, 'labels': v_labels, 'layout': 'horizontal', 'media': v_media, 'meta': v_meta, 'density': v_density}}, with_context = false) }}
{%- endif %}
{%- endfor %}
{%- set c_3 -%}
{%- for v_p in og_l(og_where(v_posts, 'category', og_get(v_filter, ['topic']))) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_gt(v_i, 0)) %}
{{ include('blocks/post-card.html.twig', {'p': {'post': v_p, 'labels': v_labels, 'media': v_media, 'meta': v_meta, 'density': v_density}}, with_context = false) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ include('compose/Grid.html.twig', {'cols': og_s(v_cols), 'class': 'gap-6', 'children': c_3}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '6', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'items']), 'children': c_4}, with_context = false) }}
{%- else %}
{%- set c_5 -%}
{%- for v_p in og_l(og_where(v_posts, 'category', og_get(v_filter, ['topic']))) %}
{{ include('blocks/post-card.html.twig', {'p': {'post': v_p, 'labels': v_labels, 'layout': (og_t(og_eq(v_layout, 'list')) ? 'horizontal' : 'vertical'), 'media': v_media, 'meta': v_meta, 'density': v_density}}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Grid.html.twig', {'cols': og_s((og_t(og_eq(v_layout, 'list')) ? '1' : og_fit_cols(v_cols, og_len(og_where(v_posts, 'category', og_get(v_filter, ['topic'])))))), 'class': 'w-full gap-6', 'attrs': og_attrs(['data-slot', 'items']), 'children': c_5}, with_context = false) }}
{%- endif %}
{%- endif %}
{%- if og_t(og_and([og_eq(og_get(v_pager, ['mode']), 'pages'), og_gt(og_len(og_where(v_posts, 'category', og_get(v_filter, ['topic']))), 0)])) %}
{%- set c_6 -%}
{{ include('blocks/pager.html.twig', {'p': {'page': og_coalesce([og_get(v_pager, ['page']), 1]), 'pages': og_coalesce([og_get(v_pager, ['pages']), 1]), 'summary': og_tpl(og_get(v_pager, ['summary']), [og_coalesce([og_get(v_pager, ['page']), 1]), og_coalesce([og_get(v_pager, ['pages']), 1])]), 'previousLabel': og_coalesce([og_get(v_pager, ['previous']), '']), 'nextLabel': og_coalesce([og_get(v_pager, ['next']), '']), 'numbered': true, 'pageLabel': og_get(v_pager, ['pageLabel']), 'pageUrl': og_get(v_pager, ['url']), 'firstUrl': og_get(v_pager, ['firstUrl'])}}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'nav', 'attrs': og_attrs(['aria-label', (og_t(v_landmarkLabel) ? og_uniq(og_tpl('{0}, {1}', [og_get(v_pager, ['label']), v_landmarkLabel])) : og_get(v_pager, ['label'])), 'data-slot', 'posts-pager']), 'children': c_6}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'action': v_action, 'tone': v_tone, 'density': (og_t(og_eq(v_density, 'compact')) ? 'compact' : 'default'), 'measure': (og_t(og_eq(v_meta, 'news')) ? 'fill' : 'default'), 'className': og_cnv([(og_t(og_eq(v_meta, 'news')) ? 'py-0' : '')]), 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_7)}, with_context = false) }}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdnnpx ui8kit add post-grid{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/post-grid.json
A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news), filter mode (none, topics), pager (none, pages), tone, density.
Props (p): id, title, posts, labels, action, filter, pager, layout, cols, media, meta, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_posts = ($p['posts'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_action = ($p['action'] ?? null)}
{var $v_filter = ($p['filter'] ?? null)}
{var $v_pager = ($p['pager'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'grid')}
{var $v_cols = ($p['cols'] ?? '1-3')}
{var $v_media = ($p['media'] ?? 'image')}
{var $v_meta = ($p['meta'] ?? 'full')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_7}
{if og_t(og_eq(og_get($v_filter, ['mode']), 'topics'))}
{capture $c_2}
{foreach og_l(og_get($v_filter, ['topics'])) as $v_tab}
{capture $c_1}
{=og_text(og_get($v_tab, ['title']))}
{/capture}
{=og_include('blocks/switcher-item.latte', ['p' => ['active' => og_eq(og_get($v_tab, ['value']), og_get($v_filter, ['topic']))], 'children' => og_markup($c_1)])|noescape}
{/foreach}
{/capture}
{=og_include('blocks/switcher.latte', ['p' => ['label' => og_get($v_filter, ['label'])], 'children' => og_markup($c_2)])|noescape}
{/if}
{if og_t(og_gt(og_len(og_where($v_posts, 'category', og_get($v_filter, ['topic']))), 0))}
{if og_t(og_eq($v_layout, 'magazine'))}
{capture $c_4}
{foreach og_l(og_where($v_posts, 'category', og_get($v_filter, ['topic']))) as $v_p}
{var $v_i = $iterator->counter0}
{if og_t(og_eq($v_i, 0))}
{=og_include('blocks/post-card.latte', ['p' => ['post' => $v_p, 'labels' => $v_labels, 'layout' => 'horizontal', 'media' => $v_media, 'meta' => $v_meta, 'density' => $v_density]])|noescape}
{/if}
{/foreach}
{capture $c_3}
{foreach og_l(og_where($v_posts, 'category', og_get($v_filter, ['topic']))) as $v_p}
{var $v_i = $iterator->counter0}
{if og_t(og_gt($v_i, 0))}
{=og_include('blocks/post-card.latte', ['p' => ['post' => $v_p, 'labels' => $v_labels, 'media' => $v_media, 'meta' => $v_meta, 'density' => $v_density]])|noescape}
{/if}
{/foreach}
{/capture}
{=og_include('compose/Grid.latte', ['cols' => og_s($v_cols), 'class' => 'gap-6', 'children' => (string) $c_3])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '6', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_4])|noescape}
{else}
{capture $c_5}
{foreach og_l(og_where($v_posts, 'category', og_get($v_filter, ['topic']))) as $v_p}
{=og_include('blocks/post-card.latte', ['p' => ['post' => $v_p, 'labels' => $v_labels, 'layout' => (og_t(og_eq($v_layout, 'list')) ? 'horizontal' : 'vertical'), 'media' => $v_media, 'meta' => $v_meta, 'density' => $v_density]])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Grid.latte', ['cols' => og_s((og_t(og_eq($v_layout, 'list')) ? '1' : og_fit_cols($v_cols, og_len(og_where($v_posts, 'category', og_get($v_filter, ['topic'])))))), 'class' => 'w-full gap-6', 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_5])|noescape}
{/if}
{/if}
{if og_t(og_and([og_eq(og_get($v_pager, ['mode']), 'pages'), og_gt(og_len(og_where($v_posts, 'category', og_get($v_filter, ['topic']))), 0)]))}
{capture $c_6}
{=og_include('blocks/pager.latte', ['p' => ['page' => og_coalesce([og_get($v_pager, ['page']), 1]), 'pages' => og_coalesce([og_get($v_pager, ['pages']), 1]), 'summary' => og_tpl(og_get($v_pager, ['summary']), [og_coalesce([og_get($v_pager, ['page']), 1]), og_coalesce([og_get($v_pager, ['pages']), 1])]), 'previousLabel' => og_coalesce([og_get($v_pager, ['previous']), '']), 'nextLabel' => og_coalesce([og_get($v_pager, ['next']), '']), 'numbered' => true, 'pageLabel' => og_get($v_pager, ['pageLabel']), 'pageUrl' => og_get($v_pager, ['url']), 'firstUrl' => og_get($v_pager, ['firstUrl'])]])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'nav', 'attrs' => og_attrs(['aria-label', (og_t($v_landmarkLabel) ? og_uniq(og_tpl('{0}, {1}', [og_get($v_pager, ['label']), $v_landmarkLabel])) : og_get($v_pager, ['label'])), 'data-slot', 'posts-pager']), 'children' => (string) $c_6])|noescape}
{/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'action' => $v_action, 'tone' => $v_tone, 'density' => (og_t(og_eq($v_density, 'compact')) ? 'compact' : 'default'), 'measure' => (og_t(og_eq($v_meta, 'news')) ? 'fill' : 'default'), 'className' => og_cnv([(og_t(og_eq($v_meta, 'news')) ? 'py-0' : '')]), 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_7)])|noescape}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdnnpx ui8kit add post-grid{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/post-grid.json
A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news), filter mode (none, topics), pager (none, pages), tone, density.
Props (p): id, title, posts, labels, action, filter, pager, layout, cols, media, meta, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_posts = og_def(p['posts'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_action = og_def(p['action'], none) -%}
{%- set v_filter = og_def(p['filter'], none) -%}
{%- set v_pager = og_def(p['pager'], none) -%}
{%- set v_layout = og_def(p['layout'], 'grid') -%}
{%- set v_cols = og_def(p['cols'], '1-3') -%}
{%- set v_media = og_def(p['media'], 'image') -%}
{%- set v_meta = og_def(p['meta'], 'full') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_7 -%}
{%- if og_t(og_eq(og_get(v_filter, ['mode']), 'topics')) %}
{%- set c_2 -%}
{%- for v_tab in og_l(og_get(v_filter, ['topics'])) %}
{%- set c_1 -%}
{{ og_text(og_get(v_tab, ['title'])) }}
{%- endset -%}
{{ og_include('blocks/switcher-item.html.j2', {'p': {'active': og_eq(og_get(v_tab, ['value']), og_get(v_filter, ['topic']))}, 'children': og_markup(c_1)}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('blocks/switcher.html.j2', {'p': {'label': og_get(v_filter, ['label'])}, 'children': og_markup(c_2)}) }}
{%- endif %}
{%- if og_t(og_gt(og_len(og_where(v_posts, 'category', og_get(v_filter, ['topic']))), 0)) %}
{%- if og_t(og_eq(v_layout, 'magazine')) %}
{%- set c_4 -%}
{%- for v_p in og_l(og_where(v_posts, 'category', og_get(v_filter, ['topic']))) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_eq(v_i, 0)) %}
{{ og_include('blocks/post-card.html.j2', {'p': {'post': v_p, 'labels': v_labels, 'layout': 'horizontal', 'media': v_media, 'meta': v_meta, 'density': v_density}}) }}
{%- endif %}
{%- endfor %}
{%- set c_3 -%}
{%- for v_p in og_l(og_where(v_posts, 'category', og_get(v_filter, ['topic']))) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_gt(v_i, 0)) %}
{{ og_include('blocks/post-card.html.j2', {'p': {'post': v_p, 'labels': v_labels, 'media': v_media, 'meta': v_meta, 'density': v_density}}) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/grid.html.j2', {'p': {'Cols': og_s(v_cols), 'Class': 'gap-6'}, 'children': c_3}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '6', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_4}) }}
{%- else %}
{%- set c_5 -%}
{%- for v_p in og_l(og_where(v_posts, 'category', og_get(v_filter, ['topic']))) %}
{{ og_include('blocks/post-card.html.j2', {'p': {'post': v_p, 'labels': v_labels, 'layout': ('horizontal' if og_t(og_eq(v_layout, 'list')) else 'vertical'), 'media': v_media, 'meta': v_meta, 'density': v_density}}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/grid.html.j2', {'p': {'Cols': og_s(('1' if og_t(og_eq(v_layout, 'list')) else og_fit_cols(v_cols, og_len(og_where(v_posts, 'category', og_get(v_filter, ['topic'])))))), 'Class': 'w-full gap-6', 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_5}) }}
{%- endif %}
{%- endif %}
{%- if og_t(og_and([og_eq(og_get(v_pager, ['mode']), 'pages'), og_gt(og_len(og_where(v_posts, 'category', og_get(v_filter, ['topic']))), 0)])) %}
{%- set c_6 -%}
{{ og_include('blocks/pager.html.j2', {'p': {'page': og_coalesce([og_get(v_pager, ['page']), 1]), 'pages': og_coalesce([og_get(v_pager, ['pages']), 1]), 'summary': og_tpl(og_get(v_pager, ['summary']), [og_coalesce([og_get(v_pager, ['page']), 1]), og_coalesce([og_get(v_pager, ['pages']), 1])]), 'previousLabel': og_coalesce([og_get(v_pager, ['previous']), '']), 'nextLabel': og_coalesce([og_get(v_pager, ['next']), '']), 'numbered': true, 'pageLabel': og_get(v_pager, ['pageLabel']), 'pageUrl': og_get(v_pager, ['url']), 'firstUrl': og_get(v_pager, ['firstUrl'])}}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'nav', 'Attrs': og_attrs(['aria-label', (og_uniq(og_tpl('{0}, {1}', [og_get(v_pager, ['label']), v_landmarkLabel])) if og_t(v_landmarkLabel) else og_get(v_pager, ['label'])), 'data-slot', 'posts-pager'])}, 'children': c_6}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'action': v_action, 'tone': v_tone, 'density': ('compact' if og_t(og_eq(v_density, 'compact')) else 'default'), 'measure': ('fill' if og_t(og_eq(v_meta, 'news')) else 'default'), 'className': og_cnv([('py-0' if og_t(og_eq(v_meta, 'news')) else '')]), 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_7)}) }}
Props
Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.
A section with a heading and the posts as cards: a grid, a list of horizontal cards, or a magazine (the first post wide, the rest in a grid). Axes: layout (grid, list, magazine), columns, media, meta (full, short, news), filter mode (none, topics), pager (none, pages), tone, density.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| posts (required) | Post[] | - | |
| labels (required) | PostLabels | - | |
| action | HeadLink | - | optional link opposite the heading (All posts) |
| filter | PostFilter | - | the topic tabs and the chosen topic |
| pager | PostPager | - | the pager under the posts (as OrderTable's): mode, page, pages and its texts |
| layout | "grid" | "list" | "magazine" | "grid" | |
| cols | "1-2" | "1-3" | "1-4" | "1-3" | |
| media | "image" | "none" | "image" | |
| meta | "full" | "short" | "news" | "full" | |
| tone | "default" | "muted" | "default" | |
| density | "default" | "compact" | "default" | |
| landmarkLabel | string | - | accessible name of the landmark of this component when the page shows it more than once (a variant); replaces the heading name of the root landmark, follows the name of a nested one |