Skip to content
ui8kit

component / components

Post Mini Card

Post Mini Card component

Install

npx ui8kit add post-mini-card

Pulls in: badge, compose, kit-box, kit-text, media-frame, post-card, stack, text, title, utils

Preview

Why static-first pages still win

· 6 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-cdn
npx ui8kit add post-mini-card
components/post-mini-card.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. -->
<!-- A small post card of PostShowcase: the picture, the category, the title and the author with the reading time. -->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Post, PostLabels } from "../blocks/post-card.types";

  export type PostMiniCardProps = {
    p: Post;
    labels: PostLabels;
  };
</script>

<script lang="ts">
  import Badge from "../compose/Badge.svelte";
  import Stack from "../compose/Stack.svelte";
  import Text from "../compose/Text.svelte";
  import Title from "../compose/Title.svelte";
  import MediaFrame from "../components/media-frame.svelte";
  import { tpl } from "../utils";

  let { p, labels }: PostMiniCardProps = $props();
</script>

<Stack gap="2" align="stretch" class="rounded bg-card inset-ring inset-ring-border p-2" data-slot="post-mini">
  <MediaFrame alt={p.title} src={p.image} />
  <Stack gap="2" align="start" class="p-2">
    <Badge variant="secondary" size="sm">
      {p.category}
    </Badge>
    <Title as={3} size="sm" weight="semibold">
      {p.title}
    </Title>
    <Text size="xs" class="text-muted-foreground">
      {tpl("{0} · {1}", p.author, tpl(labels.minutes, p.minutes))}
    </Text>
  </Stack>
</Stack>

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-mini-card
components/post-mini-card.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.
/** A small post card of PostShowcase: the picture, the category, the title and the author with the reading time. */
import { type ReactNode } from "react";
import { Badge, Stack, Text, Title } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { tpl } from "../utils";
import type { Post, PostLabels } from "../blocks/post-card.types";

export type PostMiniCardProps = {
  p: Post;
  labels: PostLabels;
};

export function PostMiniCard({ p, labels }: PostMiniCardProps) {
  return (
    <Stack
      gap="2"
      align="stretch"
      className="rounded bg-card inset-ring inset-ring-border p-2"
      data-slot="post-mini"
    >
      <MediaFrame alt={p.title} src={p.image} />
      <Stack gap="2" align="start" className="p-2">
        <Badge variant="secondary" size="sm">
          {p.category}
        </Badge>
        <Title as={3} size="sm" weight="semibold">
          {p.title}
        </Title>
        <Text size="xs" className="text-muted-foreground">
          {tpl("{0} · {1}", p.author, tpl(labels.minutes, p.minutes))}
        </Text>
      </Stack>
    </Stack>
  );
}

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-mini-card
components/post-mini-card.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. -->
<!-- A small post card of PostShowcase: the picture, the category, the title and the author with the reading time. -->
<script lang="ts">
import type { Post, PostLabels } from "../blocks/post-card.types";

export type PostMiniCardProps = {
  p: Post;
  labels: PostLabels;
};
</script>

<script setup lang="ts">
import Badge from "../compose/Badge.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import MediaFrame from "../components/media-frame.vue";
import { tpl } from "../utils";

const { p, labels } = defineProps<PostMiniCardProps>();
</script>

<template>
  <Stack gap="2" align="stretch" class="rounded bg-card inset-ring inset-ring-border p-2" data-slot="post-mini">
    <MediaFrame :alt="p.title" :src="p.image" />
    <Stack gap="2" align="start" class="p-2">
      <Badge variant="secondary" size="sm">
        {{ p.category }}
      </Badge>
      <Title :as="3" size="sm" weight="semibold">
        {{ p.title }}
      </Title>
      <Text size="xs" class="text-muted-foreground">
        {{ tpl("{0} · {1}", p.author, tpl(labels.minutes, p.minutes)) }}
      </Text>
    </Stack>
  </Stack>
</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-mini-card
components/post-mini-card.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.
/** A small post card of PostShowcase: the picture, the category, the title and the author with the reading time. */
import { type JSX } from "solid-js";
import { Badge, Stack, Text, Title } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { tpl } from "../utils";
import type { Post, PostLabels } from "../blocks/post-card.types";

export type PostMiniCardProps = {
  p: Post;
  labels: PostLabels;
};

export function PostMiniCard({ p, labels }: PostMiniCardProps) {
  return (
    <Stack gap="2" align="stretch" class="rounded bg-card inset-ring inset-ring-border p-2" data-slot="post-mini">
      <MediaFrame alt={p.title} src={p.image} />
      <Stack gap="2" align="start" class="p-2">
        <Badge variant="secondary" size="sm">
          {p.category}
        </Badge>
        <Title as={3} size="sm" weight="semibold">
          {p.title}
        </Title>
        <Text size="xs" class="text-muted-foreground">
          {tpl("{0} · {1}", p.author, tpl(labels.minutes, p.minutes))}
        </Text>
      </Stack>
    </Stack>
  );
}

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-mini-card
blocks/post-mini-card.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-mini-card.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/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// PostMiniCardProps are the props of PostMiniCard; the values are the JSON shapes of the TypeScript props.
type PostMiniCardProps struct {
	P any `json:"p"`
	Labels any `json:"labels"`
}

// A small post card of PostShowcase: the picture, the category, the title and the author with the reading time.
templ PostMiniCard(p PostMiniCardProps) {
	{{ vP := p.P }}
	{{ vLabels := p.Labels }}
	@compose.Stack(compose.StackProps{Gap: "2", Align: "stretch", BoxProps: box.BoxProps{Class: "rounded bg-card inset-ring inset-ring-border p-2", Attrs: uiutils.Attrs("data-slot", "post-mini")}}) {
		@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vP, "title"), Src: uiutils.Get(vP, "image")})
		@compose.Stack(compose.StackProps{Gap: "2", Align: "start", BoxProps: box.BoxProps{Class: "p-2"}}) {
			@compose.Badge(compose.BadgeProps{Variant: "secondary", Size: "sm", TextProps: text.TextProps{}}) {
				{ uiutils.Text(uiutils.Get(vP, "category")) }
			}
			@compose.Title(compose.TitleProps{As: "3", Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
				{ uiutils.Text(uiutils.Get(vP, "title")) }
			}
			@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
				{ uiutils.Text(uiutils.Tpl("{0} · {1}", uiutils.Get(vP, "author"), uiutils.Tpl(uiutils.Get(vLabels, "minutes"), uiutils.Get(vP, "minutes")))) }
			}
		}
	}
}

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-mini-card
blocks/post-mini-card.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-mini-card.json
    A small post card of PostShowcase: the picture, the category, the title and the author with the reading time.
    Props (p): p, labels. -#}
{%- set v_p = (p.p ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set c_5 -%}
  {{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_p, ['title']), 'src': og_get(v_p, ['image'])}}, with_context = false) }}
  {%- set c_4 -%}
    {%- set c_1 -%}
      {{ og_text(og_get(v_p, ['category'])) }}
    {%- endset -%}
    {{ include('compose/Badge.html.twig', {'variant': 'secondary', 'size': 'sm', 'children': c_1}, with_context = false) }}
    {%- set c_2 -%}
      {{ og_text(og_get(v_p, ['title'])) }}
    {%- endset -%}
    {{ include('compose/Title.html.twig', {'as': 3, 'size': 'sm', 'weight': 'semibold', 'children': c_2}, with_context = false) }}
    {%- set c_3 -%}
      {{ og_text(og_tpl('{0} · {1}', [og_get(v_p, ['author']), og_tpl(og_get(v_labels, ['minutes']), [og_get(v_p, ['minutes'])])])) }}
    {%- endset -%}
    {{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_3}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Stack.html.twig', {'gap': '2', 'align': 'start', 'class': 'p-2', 'children': c_4}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '2', 'align': 'stretch', 'class': 'rounded bg-card inset-ring inset-ring-border p-2', 'attrs': og_attrs(['data-slot', 'post-mini']), 'children': c_5}, with_context = false) }}

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-mini-card
blocks/post-mini-card.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-mini-card.json
    A small post card of PostShowcase: the picture, the category, the title and the author with the reading time.
    Props (p): p, labels. *}
{var $v_p = ($p['p'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{capture $c_5}
  {=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_p, ['title']), 'src' => og_get($v_p, ['image'])]])|noescape}
  {capture $c_4}
    {capture $c_1}
      {=og_text(og_get($v_p, ['category']))}
    {/capture}
    {=og_include('compose/Badge.latte', ['variant' => 'secondary', 'size' => 'sm', 'children' => (string) $c_1])|noescape}
    {capture $c_2}
      {=og_text(og_get($v_p, ['title']))}
    {/capture}
    {=og_include('compose/Title.latte', ['as' => 3, 'size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_2])|noescape}
    {capture $c_3}
      {=og_text(og_tpl('{0} · {1}', [og_get($v_p, ['author']), og_tpl(og_get($v_labels, ['minutes']), [og_get($v_p, ['minutes'])])]))}
    {/capture}
    {=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_3])|noescape}
  {/capture}
  {=og_include('compose/Stack.latte', ['gap' => '2', 'align' => 'start', 'class' => 'p-2', 'children' => (string) $c_4])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '2', 'align' => 'stretch', 'class' => 'rounded bg-card inset-ring inset-ring-border p-2', 'attrs' => og_attrs(['data-slot', 'post-mini']), 'children' => (string) $c_5])|noescape}

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-mini-card
blocks/post-mini-card.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-mini-card.json
    A small post card of PostShowcase: the picture, the category, the title and the author with the reading time.
    Props (p): p, labels. -#}
{%- set v_p = og_def(p['p'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set c_5 -%}
  {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_p, ['title']), 'src': og_get(v_p, ['image'])}}) }}
  {%- set c_4 -%}
    {%- set c_1 -%}
      {{ og_text(og_get(v_p, ['category'])) }}
    {%- endset -%}
    {{ og_include('compose/badge.html.j2', {'p': {'Variant': 'secondary', 'Size': 'sm'}, 'children': c_1}) }}
    {%- set c_2 -%}
      {{ og_text(og_get(v_p, ['title'])) }}
    {%- endset -%}
    {{ og_include('compose/title.html.j2', {'p': {'As': 3, 'Size': 'sm', 'Weight': 'semibold'}, 'children': c_2}) }}
    {%- set c_3 -%}
      {{ og_text(og_tpl('{0} · {1}', [og_get(v_p, ['author']), og_tpl(og_get(v_labels, ['minutes']), [og_get(v_p, ['minutes'])])])) }}
    {%- endset -%}
    {{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_3}) }}
  {%- endset -%}
  {{ og_include('compose/stack.html.j2', {'p': {'Gap': '2', 'Align': 'start', 'Class': 'p-2'}, 'children': c_4}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '2', 'Align': 'stretch', 'Class': 'rounded bg-card inset-ring inset-ring-border p-2', 'Attrs': og_attrs(['data-slot', 'post-mini'])}, 'children': c_5}) }}

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.

A small post card of PostShowcase: the picture, the category, the title and the author with the reading time.

Props of PostMiniCard
PropTypeDefault Description
p (required)Post-
labels (required)PostLabels-templates: minutes `{0} min read`, by `By {0}`; and the word of the read link

Used in