Skip to content
ui8kit

block / content

Post Showcase

Four small post cards beside an intro with a view-all link; the first post in detail beside its picture; or cards with the text on a panel over the picture, in two or three columns.

Install

npx ui8kit add post-showcase

Pulls in: box, compose, empty-state, kit-box, kit-link, link, lucide-icon, media-frame, post-card, post-feature, post-mini-card, post-overlay-card, section-frame, utils

Preview

Why static-first pages still win

· 6 min read

Design tokens without the drift

· 5 min read

Launch notes for spring

· 3 min read

Shipping with a small team

· 4 min read

Editors' picks

Worth reading this week

The posts our readers shared most, picked by the editors.

View all posts

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-cdn
npx ui8kit add post-showcase
blocks/post-showcase.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured:
  the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3:
  overlay columns), mediaSide, tone.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Post, PostLabels } from "./post-card.types";
  import type { HeadLink } from "../components/section-frame.types";

  export type PostShowcaseProps = {
    id: string;
    title: string;
    lead?: string;
    badge?: string;
    posts: Post[];
    labels: PostLabels;
    action: HeadLink;
    layout?: "intro" | "featured" | "overlay";
    cols?: "2" | "3";
    mediaSide?: "end" | "start";
    tone?: "default" | "muted";
    empty?: string;
    image?: string;
    imageAlt?: string;
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Link from "../compose/Link.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import EmptyState from "../components/empty-state.svelte";
  import MediaFrame from "../components/media-frame.svelte";
  import PostFeature from "../components/post-feature.svelte";
  import PostMiniCard from "../components/post-mini-card.svelte";
  import PostOverlayCard from "../components/post-overlay-card.svelte";
  import SectionFrame from "../components/section-frame.svelte";
  import { urlOf } from "../utils";

  let {
    id,
    title,
    lead = "",
    badge = "",
    posts,
    labels,
    action,
    layout = "intro",
    cols = "3",
    mediaSide = "start",
    tone = "default",
    empty = "",
    image,
    imageAlt,
    landmarkLabel,
  }: PostShowcaseProps = $props();
</script>

{#if ((posts?.length ?? 0) === 0)}
  <SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
    <EmptyState icon="newspaper" title={empty} />
  </SectionFrame>
{:else if ((layout as string) === "intro")}
  <SectionFrame
    id={id}
    title={title}
    lead={lead}
    heading={{ badge }}
    tone={tone}
    layout="split"
    media={{ show: true, side: mediaSide }}
    landmarkLabel={landmarkLabel}
  >
    <Link href={urlOf(action.href)} size="sm" data-slot="section-action">
      {action.label}
      <LucideIcon name="arrow-right" size={16} />
    </Link>
    {#snippet aside()}
      <Box class="grid grid-cols-1 gap-4 sm:grid-cols-2">
        {#each posts as p, i (p.id)}
          {#if (i < 4)}
            <PostMiniCard p={p} labels={labels} />
          {/if}
        {/each}
      </Box>
    {/snippet}
  </SectionFrame>
{:else if ((layout as string) === "featured")}
  <SectionFrame
    id={id}
    title={title}
    lead={lead}
    heading={{ badge }}
    tone={tone}
    layout="split"
    media={{ show: true, side: mediaSide }}
    landmarkLabel={landmarkLabel}
  >
    {#each posts as p, i (p.id)}
      {#if (i < 1)}
        <PostFeature p={p} labels={labels} />
      {/if}
    {/each}
    {#snippet aside()}
      <MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
    {/snippet}
  </SectionFrame>
{:else}
  <SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
    <Box
      class={
        (cols as string) === "2" ? "grid grid-cols-1 gap-6 md:grid-cols-2"
        : "grid grid-cols-1 gap-6 md:grid-cols-3"
      }
    >
      {#each posts as p, i (p.id)}
        {#if (i < (((cols as string) === "2") ? 2 : 3))}
          <PostOverlayCard p={p} labels={labels} ratio={(((cols as string) === "2") ? "16/9" : "4/3")} />
        {/if}
      {/each}
    </Box>
  </SectionFrame>
{/if}

Svelte registry item (JSON)

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-cdn
npx ui8kit add post-showcase
blocks/post-showcase.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured:
 * the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3:
 * overlay columns), mediaSide, tone.
 */
import { Fragment, type ReactNode } from "react";
import { Box, Link } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { PostFeature } from "../components/post-feature";
import { PostMiniCard } from "../components/post-mini-card";
import { PostOverlayCard } from "../components/post-overlay-card";
import { SectionFrame } from "../components/section-frame";
import { urlOf } from "../utils";
import type { Post, PostLabels } from "./post-card.types";
import type { HeadLink } from "../components/section-frame.types";

export type PostShowcaseProps = {
  id: string;
  title: string;
  lead?: string;
  badge?: string;
  posts: Post[];
  labels: PostLabels;
  action: HeadLink;
  layout?: "intro" | "featured" | "overlay";
  cols?: "2" | "3";
  mediaSide?: "end" | "start";
  tone?: "default" | "muted";
  empty?: string;
  image?: string;
  imageAlt?: string;
  landmarkLabel?: string;
};

export function PostShowcase({
  id,
  title,
  lead = "",
  badge = "",
  posts,
  labels,
  action,
  layout = "intro",
  cols = "3",
  mediaSide = "start",
  tone = "default",
  empty = "",
  image,
  imageAlt,
  landmarkLabel,
}: PostShowcaseProps) {
  return (
    <>
      {((posts?.length ?? 0) === 0) ? (
        <SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
          <EmptyState icon="newspaper" title={empty} />
        </SectionFrame>
      ) : ((layout as string) === "intro") ? (
        <SectionFrame
          id={id}
          title={title}
          lead={lead}
          heading={{ badge }}
          tone={tone}
          layout="split"
          media={{ show: true, side: mediaSide }}
          landmarkLabel={landmarkLabel}
          aside={(
            <Box className="grid grid-cols-1 gap-4 sm:grid-cols-2">
              {(posts ?? []).map((p, i) => (
                <Fragment key={p.id}>
                  {(i < 4) ? (
                    <PostMiniCard p={p} labels={labels} />
                  ) : null}
                </Fragment>
              ))}
            </Box>
          )}
        >
          <Link href={urlOf(action.href)} size="sm" data-slot="section-action">
            {action.label}
            <LucideIcon name="arrow-right" size={16} />
          </Link>
        </SectionFrame>
      ) : ((layout as string) === "featured") ? (
        <SectionFrame
          id={id}
          title={title}
          lead={lead}
          heading={{ badge }}
          tone={tone}
          layout="split"
          media={{ show: true, side: mediaSide }}
          landmarkLabel={landmarkLabel}
          aside={(
            <MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
          )}
        >
          {(posts ?? []).map((p, i) => (
            <Fragment key={p.id}>
              {(i < 1) ? (
                <PostFeature p={p} labels={labels} />
              ) : null}
            </Fragment>
          ))}
        </SectionFrame>
      ) : (
        <SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
          <Box
            className={
              (cols as string) === "2" ? "grid grid-cols-1 gap-6 md:grid-cols-2"
              : "grid grid-cols-1 gap-6 md:grid-cols-3"
            }
          >
            {(posts ?? []).map((p, i) => (
              <Fragment key={p.id}>
                {(i < (((cols as string) === "2") ? 2 : 3)) ? (
                  <PostOverlayCard p={p} labels={labels} ratio={(((cols as string) === "2") ? "16/9" : "4/3")} />
                ) : null}
              </Fragment>
            ))}
          </Box>
        </SectionFrame>
      )}
    </>
  );
}

React registry item (JSON)

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-cdn
npx ui8kit add post-showcase
blocks/post-showcase.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured:
  the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3:
  overlay columns), mediaSide, tone.
-->
<script lang="ts">
import type { Post, PostLabels } from "./post-card.types";
import type { HeadLink } from "../components/section-frame.types";

export type PostShowcaseProps = {
  id: string;
  title: string;
  lead?: string;
  badge?: string;
  posts: Post[];
  labels: PostLabels;
  action: HeadLink;
  layout?: "intro" | "featured" | "overlay";
  cols?: "2" | "3";
  mediaSide?: "end" | "start";
  tone?: "default" | "muted";
  empty?: string;
  image?: string;
  imageAlt?: string;
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Link from "../compose/Link.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import EmptyState from "../components/empty-state.vue";
import MediaFrame from "../components/media-frame.vue";
import PostFeature from "../components/post-feature.vue";
import PostMiniCard from "../components/post-mini-card.vue";
import PostOverlayCard from "../components/post-overlay-card.vue";
import SectionFrame from "../components/section-frame.vue";
import { urlOf } from "../utils";

const {
  id,
  title,
  lead = "",
  badge = "",
  posts,
  labels,
  action,
  layout = "intro",
  cols = "3",
  mediaSide = "start",
  tone = "default",
  empty = "",
  image,
  imageAlt,
  landmarkLabel,
} = defineProps<PostShowcaseProps>();
</script>

<template>
  <SectionFrame v-if="((posts?.length ?? 0) === 0)"
    :id="id"
    :title="title"
    :lead="lead"
    :heading="{ badge }"
    :tone="tone"
    :landmarkLabel="landmarkLabel"
  >
    <EmptyState icon="newspaper" :title="empty" />
  </SectionFrame>
  <SectionFrame v-else-if="((layout as string) === 'intro')"
    :id="id"
    :title="title"
    :lead="lead"
    :heading="{ badge }"
    :tone="tone"
    layout="split"
    :media="{ show: true, side: mediaSide }"
    :landmarkLabel="landmarkLabel"
  >
    <Link :href="urlOf(action.href)" size="sm" data-slot="section-action">
      {{ action.label }}
      <LucideIcon name="arrow-right" :size="16" />
    </Link>
    <template #aside>
      <Box class="grid grid-cols-1 gap-4 sm:grid-cols-2">
        <template v-for="(p, i) in posts" :key="p.id">
          <PostMiniCard v-if="(i < 4)" :p="p" :labels="labels" />
        </template>
      </Box>
    </template>
  </SectionFrame>
  <SectionFrame v-else-if="((layout as string) === 'featured')"
    :id="id"
    :title="title"
    :lead="lead"
    :heading="{ badge }"
    :tone="tone"
    layout="split"
    :media="{ show: true, side: mediaSide }"
    :landmarkLabel="landmarkLabel"
  >
    <template v-for="(p, i) in posts" :key="p.id">
      <PostFeature v-if="(i < 1)" :p="p" :labels="labels" />
    </template>
    <template #aside>
      <MediaFrame :alt="(imageAlt ? imageAlt : title)" :src="image" ratio="4/3" />
    </template>
  </SectionFrame>
  <SectionFrame v-else
    :id="id"
    :title="title"
    :lead="lead"
    :heading="{ badge }"
    :tone="tone"
    :landmarkLabel="landmarkLabel"
  >
    <Box
      :class="
        (cols as string) === '2' ? 'grid grid-cols-1 gap-6 md:grid-cols-2'
        : 'grid grid-cols-1 gap-6 md:grid-cols-3'
      "
    >
      <template v-for="(p, i) in posts" :key="p.id">
        <PostOverlayCard
          v-if="(i < (((cols as string) === '2') ? 2 : 3))"
          :p="p"
          :labels="labels"
          :ratio="(((cols as string) === '2') ? '16/9' : '4/3')"
        />
      </template>
    </Box>
  </SectionFrame>
</template>

Vue registry item (JSON)

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-cdn
npx ui8kit add post-showcase
blocks/post-showcase.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured:
 * the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3:
 * overlay columns), mediaSide, tone.
 */
import { For, type JSX } from "solid-js";
import { Box, Link } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { PostFeature } from "../components/post-feature";
import { PostMiniCard } from "../components/post-mini-card";
import { PostOverlayCard } from "../components/post-overlay-card";
import { SectionFrame } from "../components/section-frame";
import { urlOf } from "../utils";
import type { Post, PostLabels } from "./post-card.types";
import type { HeadLink } from "../components/section-frame.types";

export type PostShowcaseProps = {
  id: string;
  title: string;
  lead?: string;
  badge?: string;
  posts: Post[];
  labels: PostLabels;
  action: HeadLink;
  layout?: "intro" | "featured" | "overlay";
  cols?: "2" | "3";
  mediaSide?: "end" | "start";
  tone?: "default" | "muted";
  empty?: string;
  image?: string;
  imageAlt?: string;
  landmarkLabel?: string;
};

export function PostShowcase({
  id,
  title,
  lead = "",
  badge = "",
  posts,
  labels,
  action,
  layout = "intro",
  cols = "3",
  mediaSide = "start",
  tone = "default",
  empty = "",
  image,
  imageAlt,
  landmarkLabel,
}: PostShowcaseProps) {
  return (
    <>
      {((posts?.length ?? 0) === 0) ? (
        <SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
          <EmptyState icon="newspaper" title={empty} />
        </SectionFrame>
      ) : ((layout as string) === "intro") ? (
        <SectionFrame
          id={id}
          title={title}
          lead={lead}
          heading={{ badge }}
          tone={tone}
          layout="split"
          media={{ show: true, side: mediaSide }}
          landmarkLabel={landmarkLabel}
          aside={(
            <Box class="grid grid-cols-1 gap-4 sm:grid-cols-2">
              <For each={posts ?? []}>{(p, iOf) => { const i = iOf(); return (
                <>
                  {(i < 4) ? (
                    <PostMiniCard p={p} labels={labels} />
                  ) : null}
                </>
              ); }}</For>
            </Box>
          )}
        >
          <Link href={urlOf(action.href)} size="sm" data-slot="section-action">
            {action.label}
            <LucideIcon name="arrow-right" size={16} />
          </Link>
        </SectionFrame>
      ) : ((layout as string) === "featured") ? (
        <SectionFrame
          id={id}
          title={title}
          lead={lead}
          heading={{ badge }}
          tone={tone}
          layout="split"
          media={{ show: true, side: mediaSide }}
          landmarkLabel={landmarkLabel}
          aside={(
            <MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
          )}
        >
          <For each={posts ?? []}>{(p, iOf) => { const i = iOf(); return (
            <>
              {(i < 1) ? (
                <PostFeature p={p} labels={labels} />
              ) : null}
            </>
          ); }}</For>
        </SectionFrame>
      ) : (
        <SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
          <Box
            class={
              (cols as string) === "2" ? "grid grid-cols-1 gap-6 md:grid-cols-2"
              : "grid grid-cols-1 gap-6 md:grid-cols-3"
            }
          >
            <For each={posts ?? []}>{(p, iOf) => { const i = iOf(); return (
              <>
                {(i < (((cols as string) === "2") ? 2 : 3)) ? (
                  <PostOverlayCard p={p} labels={labels} ratio={(((cols as string) === "2") ? "16/9" : "4/3")} />
                ) : null}
              </>
            ); }}</For>
          </Box>
        </SectionFrame>
      )}
    </>
  );
}

Solid registry item (JSON)

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-cdn
npx ui8kit add post-showcase
blocks/post-showcase.templ
// 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-showcase.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/compose"
	"github.com/ui8kit/codegen/generated/templ/icons"
	"github.com/ui8kit/codegen/generated/templ/ui/link"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// PostShowcaseProps are the props of PostShowcase; the values are the JSON shapes of the TypeScript props.
type PostShowcaseProps struct {
	Id any `json:"id"`
	Title any `json:"title"`
	Lead any `json:"lead"`
	Badge any `json:"badge"`
	Posts any `json:"posts"`
	Labels any `json:"labels"`
	Action any `json:"action"`
	Layout any `json:"layout"`
	Cols any `json:"cols"`
	MediaSide any `json:"mediaSide"`
	Tone any `json:"tone"`
	Empty any `json:"empty"`
	Image any `json:"image"`
	ImageAlt any `json:"imageAlt"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured: the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3: overlay columns), mediaSide, tone.
templ PostShowcase(p PostShowcaseProps) {
	{{ vId := p.Id }}
	{{ vTitle := p.Title }}
	{{ vLead := uiutils.Def(p.Lead, "") }}
	{{ vBadge := uiutils.Def(p.Badge, "") }}
	{{ vPosts := p.Posts }}
	{{ vLabels := p.Labels }}
	{{ vAction := p.Action }}
	{{ vLayout := uiutils.Def(p.Layout, "intro") }}
	{{ vCols := uiutils.Def(p.Cols, "3") }}
	{{ vMediaSide := uiutils.Def(p.MediaSide, "start") }}
	{{ vTone := uiutils.Def(p.Tone, "default") }}
	{{ vEmpty := uiutils.Def(p.Empty, "") }}
	{{ vImage := p.Image }}
	{{ vImageAlt := p.ImageAlt }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	if uiutils.Eq(uiutils.Len(vPosts), float64(0)) {
		@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Heading: map[string]any{"badge": vBadge}, Tone: vTone, LandmarkLabel: vLandmarkLabel}) {
			@EmptyState(EmptyStateProps{Icon: "newspaper", Title: vEmpty})
		}
	} else if uiutils.Eq(vLayout, "intro") {
		@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Heading: map[string]any{"badge": vBadge}, Tone: vTone, Layout: "split", Media: map[string]any{"show": true, "side": vMediaSide}, LandmarkLabel: vLandmarkLabel, Aside: postShowcaseFill1(p, vPosts, vLabels)}) {
			@compose.Link(compose.LinkProps{Size: "sm", LinkProps: link.LinkProps{Href: uiutils.URL(uiutils.Get(vAction, "href"), false), Attrs: uiutils.Attrs("data-slot", "section-action")}}) {
				{ uiutils.Text(uiutils.Get(vAction, "label")) }
				@icons.LucideIcon(icons.LucideIconProps{Name: "arrow-right", Size: 16})
			}
		}
	} else if uiutils.Eq(vLayout, "featured") {
		@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Heading: map[string]any{"badge": vBadge}, Tone: vTone, Layout: "split", Media: map[string]any{"show": true, "side": vMediaSide}, LandmarkLabel: vLandmarkLabel, Aside: postShowcaseFill2(p, vTitle, vImage, vImageAlt)}) {
			for vI, vP := range uiutils.L(vPosts) {
				if uiutils.Lt(float64(vI), float64(1)) {
					@PostFeature(PostFeatureProps{P: vP, Labels: vLabels})
				}
			}
		}
	} else {
		@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Heading: map[string]any{"badge": vBadge}, Tone: vTone, LandmarkLabel: vLandmarkLabel}) {
			@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "2")), "grid grid-cols-1 gap-6 md:grid-cols-2", "grid grid-cols-1 gap-6 md:grid-cols-3"))}}) {
				for vI, vP := range uiutils.L(vPosts) {
					if uiutils.T(uiutils.Lt(float64(vI), uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "2")), float64(2), float64(3)))) {
						@PostOverlayCard(PostOverlayCardProps{P: vP, Labels: vLabels, Ratio: uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "2")), "16/9", "4/3")})
					}
				}
			}
		}
	}
}

templ postShowcaseFill1(p PostShowcaseProps, vPosts any, vLabels any) {
	@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "grid grid-cols-1 gap-4 sm:grid-cols-2"}}) {
		for vI, vP := range uiutils.L(vPosts) {
			if uiutils.Lt(float64(vI), float64(4)) {
				@PostMiniCard(PostMiniCardProps{P: vP, Labels: vLabels})
			}
		}
	}
}

templ postShowcaseFill2(p PostShowcaseProps, vTitle any, vImage any, vImageAlt any) {
	@MediaFrame(MediaFrameProps{Alt: uiutils.Cond(uiutils.T(vImageAlt), vImageAlt, vTitle), Src: vImage, Ratio: "4/3"})
}

templ registry item (JSON)

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-cdn
npx ui8kit add post-showcase
blocks/post-showcase.html.twig
{#- 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-showcase.json
    Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured: the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3: overlay columns), mediaSide, tone.
    Props (p): id, title, lead, badge, posts, labels, action, layout, cols, mediaSide, tone, empty, image, imageAlt, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_lead = (p.lead ?? '') -%}
{%- set v_badge = (p.badge ?? '') -%}
{%- set v_posts = (p.posts ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_action = (p.action ?? null) -%}
{%- set v_layout = (p.layout ?? 'intro') -%}
{%- set v_cols = (p.cols ?? '3') -%}
{%- set v_mediaSide = (p.mediaSide ?? 'start') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_image = (p.image ?? null) -%}
{%- set v_imageAlt = (p.imageAlt ?? null) -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- if og_t(og_eq(og_len(v_posts), 0)) %}
  {%- set c_1 -%}
    {{ include('blocks/empty-state.html.twig', {'p': {'icon': 'newspaper', 'title': v_empty}}, with_context = false) }}
  {%- endset -%}
  {{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_1)}, with_context = false) }}
{%- elseif og_t(og_eq(v_layout, 'intro')) %}
  {%- set f_3 -%}
    {%- set c_4 -%}
      {%- for v_p in og_l(v_posts) %}
        {%- set v_i = loop.index0 -%}
        {%- if og_t(og_lt(v_i, 4)) %}
          {{ include('blocks/post-mini-card.html.twig', {'p': {'p': v_p, 'labels': v_labels}}, with_context = false) }}
        {%- endif %}
      {%- endfor %}
    {%- endset -%}
    {{ include('compose/Box.html.twig', {'class': 'grid grid-cols-1 gap-4 sm:grid-cols-2', 'children': c_4}, with_context = false) }}
  {%- endset -%}
  {%- set c_5 -%}
    {%- set c_2 -%}
      {{ og_text(og_get(v_action, ['label'])) }}
      {{ include('icons/LucideIcon.html.twig', {'name': 'arrow-right', 'size': 16}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Link.html.twig', {'href': og_url(og_s(og_get(v_action, ['href']))), 'size': 'sm', 'attrs': og_attrs(['data-slot', 'section-action']), 'children': c_2}, with_context = false) }}
  {%- endset -%}
  {{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'layout': 'split', 'media': {'show': true, 'side': v_mediaSide}, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_3)}, 'children': og_markup(c_5)}, with_context = false) }}
{%- elseif og_t(og_eq(v_layout, 'featured')) %}
  {%- set f_6 -%}
    {{ include('blocks/media-frame.html.twig', {'p': {'alt': (og_t(v_imageAlt) ? v_imageAlt : v_title), 'src': v_image, 'ratio': '4/3'}}, with_context = false) }}
  {%- endset -%}
  {%- set c_7 -%}
    {%- for v_p in og_l(v_posts) %}
      {%- set v_i = loop.index0 -%}
      {%- if og_t(og_lt(v_i, 1)) %}
        {{ include('blocks/post-feature.html.twig', {'p': {'p': v_p, 'labels': v_labels}}, with_context = false) }}
      {%- endif %}
    {%- endfor %}
  {%- endset -%}
  {{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'layout': 'split', 'media': {'show': true, 'side': v_mediaSide}, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_6)}, 'children': og_markup(c_7)}, with_context = false) }}
{%- else %}
  {%- set c_9 -%}
    {%- set c_8 -%}
      {%- for v_p in og_l(v_posts) %}
        {%- set v_i = loop.index0 -%}
        {%- if og_t(og_lt(v_i, (og_t(og_eq(v_cols, '2')) ? 2 : 3))) %}
          {{ include('blocks/post-overlay-card.html.twig', {'p': {'p': v_p, 'labels': v_labels, 'ratio': (og_t(og_eq(v_cols, '2')) ? '16/9' : '4/3')}}, with_context = false) }}
        {%- endif %}
      {%- endfor %}
    {%- endset -%}
    {{ include('compose/Box.html.twig', {'class': og_s((og_t(og_eq(v_cols, '2')) ? 'grid grid-cols-1 gap-6 md:grid-cols-2' : 'grid grid-cols-1 gap-6 md:grid-cols-3')), 'children': c_8}, with_context = false) }}
  {%- endset -%}
  {{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_9)}, with_context = false) }}
{%- endif %}

Twig registry item (JSON)

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-cdn
npx ui8kit add post-showcase
blocks/post-showcase.latte
{* 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-showcase.json
    Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured: the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3: overlay columns), mediaSide, tone.
    Props (p): id, title, lead, badge, posts, labels, action, layout, cols, mediaSide, tone, empty, image, imageAlt, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_lead = ($p['lead'] ?? '')}
{var $v_badge = ($p['badge'] ?? '')}
{var $v_posts = ($p['posts'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_action = ($p['action'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'intro')}
{var $v_cols = ($p['cols'] ?? '3')}
{var $v_mediaSide = ($p['mediaSide'] ?? 'start')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_image = ($p['image'] ?? null)}
{var $v_imageAlt = ($p['imageAlt'] ?? null)}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{if og_t(og_eq(og_len($v_posts), 0))}
  {capture $c_1}
    {=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'newspaper', 'title' => $v_empty]])|noescape}
  {/capture}
  {=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'heading' => ['badge' => $v_badge], 'tone' => $v_tone, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_1)])|noescape}
{elseif og_t(og_eq($v_layout, 'intro'))}
  {capture $f_3}
    {capture $c_4}
      {foreach og_l($v_posts) as $v_p}
        {var $v_i = $iterator->counter0}
        {if og_t(og_lt($v_i, 4))}
          {=og_include('blocks/post-mini-card.latte', ['p' => ['p' => $v_p, 'labels' => $v_labels]])|noescape}
        {/if}
      {/foreach}
    {/capture}
    {=og_include('compose/Box.latte', ['class' => 'grid grid-cols-1 gap-4 sm:grid-cols-2', 'children' => (string) $c_4])|noescape}
  {/capture}
  {capture $c_5}
    {capture $c_2}
      {=og_text(og_get($v_action, ['label']))}
      {=og_include('icons/LucideIcon.latte', ['name' => 'arrow-right', 'size' => 16])|noescape}
    {/capture}
    {=og_include('compose/Link.latte', ['href' => og_url(og_s(og_get($v_action, ['href']))), 'size' => 'sm', 'attrs' => og_attrs(['data-slot', 'section-action']), 'children' => (string) $c_2])|noescape}
  {/capture}
  {=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'heading' => ['badge' => $v_badge], 'tone' => $v_tone, 'layout' => 'split', 'media' => ['show' => true, 'side' => $v_mediaSide], 'landmarkLabel' => $v_landmarkLabel, 'aside' => og_markup($f_3)], 'children' => og_markup($c_5)])|noescape}
{elseif og_t(og_eq($v_layout, 'featured'))}
  {capture $f_6}
    {=og_include('blocks/media-frame.latte', ['p' => ['alt' => (og_t($v_imageAlt) ? $v_imageAlt : $v_title), 'src' => $v_image, 'ratio' => '4/3']])|noescape}
  {/capture}
  {capture $c_7}
    {foreach og_l($v_posts) as $v_p}
      {var $v_i = $iterator->counter0}
      {if og_t(og_lt($v_i, 1))}
        {=og_include('blocks/post-feature.latte', ['p' => ['p' => $v_p, 'labels' => $v_labels]])|noescape}
      {/if}
    {/foreach}
  {/capture}
  {=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'heading' => ['badge' => $v_badge], 'tone' => $v_tone, 'layout' => 'split', 'media' => ['show' => true, 'side' => $v_mediaSide], 'landmarkLabel' => $v_landmarkLabel, 'aside' => og_markup($f_6)], 'children' => og_markup($c_7)])|noescape}
{else}
  {capture $c_9}
    {capture $c_8}
      {foreach og_l($v_posts) as $v_p}
        {var $v_i = $iterator->counter0}
        {if og_t(og_lt($v_i, (og_t(og_eq($v_cols, '2')) ? 2 : 3)))}
          {=og_include('blocks/post-overlay-card.latte', ['p' => ['p' => $v_p, 'labels' => $v_labels, 'ratio' => (og_t(og_eq($v_cols, '2')) ? '16/9' : '4/3')]])|noescape}
        {/if}
      {/foreach}
    {/capture}
    {=og_include('compose/Box.latte', ['class' => og_s((og_t(og_eq($v_cols, '2')) ? 'grid grid-cols-1 gap-6 md:grid-cols-2' : 'grid grid-cols-1 gap-6 md:grid-cols-3')), 'children' => (string) $c_8])|noescape}
  {/capture}
  {=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'heading' => ['badge' => $v_badge], 'tone' => $v_tone, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_9)])|noescape}
{/if}

Latte registry item (JSON)

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-cdn
npx ui8kit add post-showcase
blocks/post-showcase.html.j2
{#- 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-showcase.json
    Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured: the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3: overlay columns), mediaSide, tone.
    Props (p): id, title, lead, badge, posts, labels, action, layout, cols, mediaSide, tone, empty, image, imageAlt, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_lead = og_def(p['lead'], '') -%}
{%- set v_badge = og_def(p['badge'], '') -%}
{%- 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_layout = og_def(p['layout'], 'intro') -%}
{%- set v_cols = og_def(p['cols'], '3') -%}
{%- set v_mediaSide = og_def(p['mediaSide'], 'start') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_image = og_def(p['image'], none) -%}
{%- set v_imageAlt = og_def(p['imageAlt'], none) -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- if og_t(og_eq(og_len(v_posts), 0)) %}
  {%- set c_1 -%}
    {{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'newspaper', 'title': v_empty}}) }}
  {%- endset -%}
  {{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_1)}) }}
{%- elif og_t(og_eq(v_layout, 'intro')) %}
  {%- set f_3 -%}
    {%- set c_4 -%}
      {%- for v_p in og_l(v_posts) %}
        {%- set v_i = loop.index0 -%}
        {%- if og_t(og_lt(v_i, 4)) %}
          {{ og_include('blocks/post-mini-card.html.j2', {'p': {'p': v_p, 'labels': v_labels}}) }}
        {%- endif %}
      {%- endfor %}
    {%- endset -%}
    {{ og_include('compose/box.html.j2', {'p': {'Class': 'grid grid-cols-1 gap-4 sm:grid-cols-2'}, 'children': c_4}) }}
  {%- endset -%}
  {%- set c_5 -%}
    {%- set c_2 -%}
      {{ og_text(og_get(v_action, ['label'])) }}
      {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'arrow-right', 'Size': 16}}) }}
    {%- endset -%}
    {{ og_include('compose/link.html.j2', {'p': {'Href': og_url(og_s(og_get(v_action, ['href']))), 'Size': 'sm', 'Attrs': og_attrs(['data-slot', 'section-action'])}, 'children': c_2}) }}
  {%- endset -%}
  {{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'layout': 'split', 'media': {'show': true, 'side': v_mediaSide}, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_3)}, 'children': og_markup(c_5)}) }}
{%- elif og_t(og_eq(v_layout, 'featured')) %}
  {%- set f_6 -%}
    {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': (v_imageAlt if og_t(v_imageAlt) else v_title), 'src': v_image, 'ratio': '4/3'}}) }}
  {%- endset -%}
  {%- set c_7 -%}
    {%- for v_p in og_l(v_posts) %}
      {%- set v_i = loop.index0 -%}
      {%- if og_t(og_lt(v_i, 1)) %}
        {{ og_include('blocks/post-feature.html.j2', {'p': {'p': v_p, 'labels': v_labels}}) }}
      {%- endif %}
    {%- endfor %}
  {%- endset -%}
  {{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'layout': 'split', 'media': {'show': true, 'side': v_mediaSide}, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_6)}, 'children': og_markup(c_7)}) }}
{%- else %}
  {%- set c_9 -%}
    {%- set c_8 -%}
      {%- for v_p in og_l(v_posts) %}
        {%- set v_i = loop.index0 -%}
        {%- if og_t(og_lt(v_i, (2 if og_t(og_eq(v_cols, '2')) else 3))) %}
          {{ og_include('blocks/post-overlay-card.html.j2', {'p': {'p': v_p, 'labels': v_labels, 'ratio': ('16/9' if og_t(og_eq(v_cols, '2')) else '4/3')}}) }}
        {%- endif %}
      {%- endfor %}
    {%- endset -%}
    {{ og_include('compose/box.html.j2', {'p': {'Class': og_s(('grid grid-cols-1 gap-6 md:grid-cols-2' if og_t(og_eq(v_cols, '2')) else 'grid grid-cols-1 gap-6 md:grid-cols-3'))}, 'children': c_8}) }}
  {%- endset -%}
  {{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_9)}) }}
{%- endif %}

Jinja2 registry item (JSON)

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.

Posts shown off. Axes: layout (intro: four small post cards beside the intro with a view-all link, featured: the first post in detail beside its picture, overlay: cards with the text over the picture), cols (2, 3: overlay columns), mediaSide, tone.

Props of PostShowcase
PropTypeDefault Description
id (required)string-
title (required)string-
lead string""
badge string""a short pill above the heading
posts (required)Post[]-
labels (required)PostLabels-
action (required)HeadLink-the view-all link of the intro layout
layout "intro" | "featured" | "overlay""intro"
cols "2" | "3""3"
mediaSide "end" | "start""start"
tone "default" | "muted""default"
empty string""the text of the empty state (no records), from the dictionary
image string-address of the picture (an https URL or a path); none: the placeholder
imageAlt string-alt text of the picture; none: the title
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