Media Posts
Media Posts component
Install
npx ui8kit add media-postsPulls in: compose, group, inline, kit-box, kit-text, media-list, menu-entry, stack, text, utils
Preview
Latest posts
Mar 18, 2026 · 6 min read
Mar 11, 2026 · 5 min read
Mar 04, 2026 · 3 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 media-posts<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- The latest posts of MediaList as rows: a dot, the title, the date and reading time. -->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { MediaExtras, MediaListLabels } from "../blocks/media-list.types";
export type MediaPostsProps = {
extras: MediaExtras;
labels: MediaListLabels;
};
</script>
<script lang="ts">
import Group from "../compose/Group.svelte";
import Inline from "../compose/Inline.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import MenuEntry from "../components/menu-entry.svelte";
import { tpl } from "../utils";
let { extras, labels }: MediaPostsProps = $props();
</script>
<Stack gap="4" align="stretch" data-slot="media-posts">
<Text size="sm" weight="semibold">
{labels.list}
</Text>
{#each extras.posts as p, i (p.id)}
{#if (i < 3)}
<Group gap="4" align="start" data-slot="media-post">
<Inline class="mt-2 size-2 shrink-0 rounded-full bg-primary" />
<Stack gap="0">
<MenuEntry href={p.href} class="text-sm font-medium" size="sm">
{p.title}
</MenuEntry>
<Text size="xs" class="text-muted-foreground">
{tpl("{0} · {1}", p.date, tpl(labels.minutes, p.minutes))}
</Text>
</Stack>
</Group>
{/if}
{/each}
</Stack>
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 media-posts// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** The latest posts of MediaList as rows: a dot, the title, the date and reading time. */
import { Fragment, type ReactNode } from "react";
import { Group, Inline, Stack, Text } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { tpl } from "../utils";
import type { MediaExtras, MediaListLabels } from "../blocks/media-list.types";
export type MediaPostsProps = {
extras: MediaExtras;
labels: MediaListLabels;
};
export function MediaPosts({ extras, labels }: MediaPostsProps) {
return (
<Stack gap="4" align="stretch" data-slot="media-posts">
<Text size="sm" weight="semibold">
{labels.list}
</Text>
{(extras.posts ?? []).map((p, i) => (
<Fragment key={p.id}>
{(i < 3) ? (
<Group gap="4" align="start" data-slot="media-post">
<Inline className="mt-2 size-2 shrink-0 rounded-full bg-primary" />
<Stack gap="0">
<MenuEntry href={p.href} className="text-sm font-medium" size="sm">
{p.title}
</MenuEntry>
<Text size="xs" className="text-muted-foreground">
{tpl("{0} · {1}", p.date, tpl(labels.minutes, p.minutes))}
</Text>
</Stack>
</Group>
) : null}
</Fragment>
))}
</Stack>
);
}
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 media-posts<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- The latest posts of MediaList as rows: a dot, the title, the date and reading time. -->
<script lang="ts">
import type { MediaExtras, MediaListLabels } from "../blocks/media-list.types";
export type MediaPostsProps = {
extras: MediaExtras;
labels: MediaListLabels;
};
</script>
<script setup lang="ts">
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import MenuEntry from "../components/menu-entry.vue";
import { tpl } from "../utils";
const { extras, labels } = defineProps<MediaPostsProps>();
</script>
<template>
<Stack gap="4" align="stretch" data-slot="media-posts">
<Text size="sm" weight="semibold">
{{ labels.list }}
</Text>
<template v-for="(p, i) in extras.posts" :key="p.id">
<Group v-if="(i < 3)" gap="4" align="start" data-slot="media-post">
<Inline class="mt-2 size-2 shrink-0 rounded-full bg-primary" />
<Stack gap="0">
<MenuEntry :href="p.href" class="text-sm font-medium" size="sm">
{{ p.title }}
</MenuEntry>
<Text size="xs" class="text-muted-foreground">
{{ tpl("{0} · {1}", p.date, tpl(labels.minutes, p.minutes)) }}
</Text>
</Stack>
</Group>
</template>
</Stack>
</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 media-posts// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** The latest posts of MediaList as rows: a dot, the title, the date and reading time. */
import { For, type JSX } from "solid-js";
import { Group, Inline, Stack, Text } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { tpl } from "../utils";
import type { MediaExtras, MediaListLabels } from "../blocks/media-list.types";
export type MediaPostsProps = {
extras: MediaExtras;
labels: MediaListLabels;
};
export function MediaPosts({ extras, labels }: MediaPostsProps) {
return (
<Stack gap="4" align="stretch" data-slot="media-posts">
<Text size="sm" weight="semibold">
{labels.list}
</Text>
<For each={extras.posts ?? []}>{(p, iOf) => { const i = iOf(); return (
<>
{(i < 3) ? (
<Group gap="4" align="start" data-slot="media-post">
<Inline class="mt-2 size-2 shrink-0 rounded-full bg-primary" />
<Stack gap="0">
<MenuEntry href={p.href} class="text-sm font-medium" size="sm">
{p.title}
</MenuEntry>
<Text size="xs" class="text-muted-foreground">
{tpl("{0} · {1}", p.date, tpl(labels.minutes, p.minutes))}
</Text>
</Stack>
</Group>
) : null}
</>
); }}</For>
</Stack>
);
}
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 media-posts// 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/media-posts.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"
)
// MediaPostsProps are the props of MediaPosts; the values are the JSON shapes of the TypeScript props.
type MediaPostsProps struct {
Extras any `json:"extras"`
Labels any `json:"labels"`
}
// The latest posts of MediaList as rows: a dot, the title, the date and reading time.
templ MediaPosts(p MediaPostsProps) {
{{ vExtras := p.Extras }}
{{ vLabels := p.Labels }}
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "media-posts")}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vLabels, "list")) }
}
for vI, vP := range uiutils.L(uiutils.Get(vExtras, "posts")) {
if uiutils.Lt(float64(vI), float64(3)) {
@compose.Group(compose.GroupProps{Gap: "4", Align: "start", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "media-post")}}) {
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "mt-2 size-2 shrink-0 rounded-full bg-primary"}})
@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{}}) {
@MenuEntry(MenuEntryProps{Href: uiutils.Get(vP, "href"), Class: uiutils.Cnv("text-sm font-medium"), Size: "sm"}) {
{ 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, "date"), uiutils.Tpl(uiutils.Get(vLabels, "minutes"), uiutils.Get(vP, "minutes")))) }
}
}
}
}
}
}
}
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 media-posts{#- 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/media-posts.json
The latest posts of MediaList as rows: a dot, the title, the date and reading time.
Props (p): extras, labels. -#}
{%- set v_extras = (p.extras ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set c_6 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_labels, ['list'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_1}, with_context = false) }}
{%- for v_p in og_l(og_get(v_extras, ['posts'])) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_lt(v_i, 3)) %}
{%- set c_5 -%}
{{ include('compose/Inline.html.twig', {'class': 'mt-2 size-2 shrink-0 rounded-full bg-primary'}, with_context = false) }}
{%- set c_4 -%}
{%- set c_2 -%}
{{ og_text(og_get(v_p, ['title'])) }}
{%- endset -%}
{{ include('blocks/menu-entry.html.twig', {'p': {'href': og_get(v_p, ['href']), 'className': og_cnv(['text-sm font-medium']), 'size': 'sm'}, 'children': og_markup(c_2)}, with_context = false) }}
{%- set c_3 -%}
{{ og_text(og_tpl('{0} · {1}', [og_get(v_p, ['date']), 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': '0', 'children': c_4}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'start', 'attrs': og_attrs(['data-slot', 'media-post']), 'children': c_5}, with_context = false) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'media-posts']), 'children': c_6}, 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 media-posts{* 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/media-posts.json
The latest posts of MediaList as rows: a dot, the title, the date and reading time.
Props (p): extras, labels. *}
{var $v_extras = ($p['extras'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{capture $c_6}
{capture $c_1}
{=og_text(og_get($v_labels, ['list']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_1])|noescape}
{foreach og_l(og_get($v_extras, ['posts'])) as $v_p}
{var $v_i = $iterator->counter0}
{if og_t(og_lt($v_i, 3))}
{capture $c_5}
{=og_include('compose/Inline.latte', ['class' => 'mt-2 size-2 shrink-0 rounded-full bg-primary'])|noescape}
{capture $c_4}
{capture $c_2}
{=og_text(og_get($v_p, ['title']))}
{/capture}
{=og_include('blocks/menu-entry.latte', ['p' => ['href' => og_get($v_p, ['href']), 'className' => og_cnv(['text-sm font-medium']), 'size' => 'sm'], 'children' => og_markup($c_2)])|noescape}
{capture $c_3}
{=og_text(og_tpl('{0} · {1}', [og_get($v_p, ['date']), 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' => '0', 'children' => (string) $c_4])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'start', 'attrs' => og_attrs(['data-slot', 'media-post']), 'children' => (string) $c_5])|noescape}
{/if}
{/foreach}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'media-posts']), 'children' => (string) $c_6])|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 media-posts{#- 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/media-posts.json
The latest posts of MediaList as rows: a dot, the title, the date and reading time.
Props (p): extras, labels. -#}
{%- set v_extras = og_def(p['extras'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set c_6 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_labels, ['list'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_1}) }}
{%- for v_p in og_l(og_get(v_extras, ['posts'])) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_lt(v_i, 3)) %}
{%- set c_5 -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'mt-2 size-2 shrink-0 rounded-full bg-primary'}}) }}
{%- set c_4 -%}
{%- set c_2 -%}
{{ og_text(og_get(v_p, ['title'])) }}
{%- endset -%}
{{ og_include('blocks/menu-entry.html.j2', {'p': {'href': og_get(v_p, ['href']), 'className': og_cnv(['text-sm font-medium']), 'size': 'sm'}, 'children': og_markup(c_2)}) }}
{%- set c_3 -%}
{{ og_text(og_tpl('{0} · {1}', [og_get(v_p, ['date']), 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': '0'}, 'children': c_4}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'start', 'Attrs': og_attrs(['data-slot', 'media-post'])}, 'children': c_5}) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'media-posts'])}, 'children': c_6}) }}
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.
The latest posts of MediaList as rows: a dot, the title, the date and reading time.
| Prop | Type | Default | Description |
|---|---|---|---|
| extras (required) | MediaExtras | - | |
| labels (required) | MediaListLabels | - |