Post Split
Tags, reading figures and an author card with share and save over a wide cover; the author, figures, tags and actions beside the cover; or the facts and related reading beside it.
Install
npx ui8kit add post-splitPulls in: media-frame, nav-bar, post-actions, post-author, post-card, post-outline, post-stats, post-tags, section-frame, utils
Preview
Why static-first pages still win
Less script, less waiting, and pages that keep working offline.
6 min read
12.8K views
892 likes
Head of Growth
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-split<!-- 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 post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags,
figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and
related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair,
wide, icons), tone.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { PostExtras, PostSplitLabels } from "./post-split.types";
import type { Post } from "./post-card.types";
import type { NavLink } from "./nav-bar.types";
export type PostSplitProps = {
id: string;
post: Post;
labels: PostSplitLabels;
extras: PostExtras;
level?: 1 | 2;
layout?: "center" | "split" | "outline";
mediaSide?: "end" | "start";
author?: "line" | "card" | "bio";
cover?: "wide" | "square";
actions?: "pair" | "wide" | "icons";
tone?: "default" | "muted";
landmarkLabel?: string;
};
</script>
<script lang="ts">
import MediaFrame from "../components/media-frame.svelte";
import PostActions from "../components/post-actions.svelte";
import PostAuthor from "../components/post-author.svelte";
import PostOutline from "../components/post-outline.svelte";
import PostStats from "../components/post-stats.svelte";
import PostTags from "../components/post-tags.svelte";
import SectionFrame from "../components/section-frame.svelte";
let {
id,
post,
labels,
extras,
level = 1,
layout = "split",
mediaSide = "end",
author = "line",
cover = "wide",
actions = "pair",
tone = "default",
landmarkLabel,
}: PostSplitProps = $props();
</script>
{#if ((layout as string) === "center")}
<SectionFrame
id={id}
title={post.title}
lead={post.excerpt}
heading={{ badge: post.category, level }}
tone={tone}
media={{ show: true }}
align="center"
landmarkLabel={landmarkLabel}
>
{#if ((extras.tags?.length ?? 0) > 0)}
<PostTags tags={extras.tags} align="center" />
{/if}
<PostStats post={post} extras={extras} labels={labels} align="center" />
<PostAuthor
post={post}
extras={extras}
labels={labels}
mode="card"
share={true}
class="mx-auto w-full max-w-md"
/>
{#snippet aside()}
<MediaFrame
alt={post.title}
src={post.image}
ratio={
(layout as string) === "center" ? "21/9"
: (cover as string) === "square" ? "1/1"
: "4/3"
}
/>
{/snippet}
</SectionFrame>
{:else}
<SectionFrame
id={id}
title={post.title}
lead={post.excerpt}
heading={{ badge: post.category, level }}
tone={tone}
media={{ show: true, side: mediaSide }}
layout="split"
landmarkLabel={landmarkLabel}
>
{#if ((layout as string) === "outline")}
{#if ((extras.outline?.length ?? 0) > 0)}
<PostOutline post={post} extras={extras} labels={labels} />
{/if}
{:else}
<PostAuthor post={post} extras={extras} labels={labels} mode={author} />
{#if ((author as string) !== "line")}
<PostStats post={post} extras={extras} labels={labels} />
{/if}
{#if ((extras.tags?.length ?? 0) > 0)}
<PostTags tags={extras.tags} />
{/if}
{/if}
<PostActions labels={labels} mode={actions} />
{#snippet aside()}
<MediaFrame
alt={post.title}
src={post.image}
ratio={
(layout as string) === "center" ? "21/9"
: (cover as string) === "square" ? "1/1"
: "4/3"
}
/>
{/snippet}
</SectionFrame>
{/if}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
import type { NavLink } from "./nav-bar.types";
export type PostExtras = {
role: string;
bio: string;
views: string;
likes: string;
tags: NavLink[];
outline: NavLink[];
};
export type PostSplitLabels = {
minutes: string;
views: string;
likes: string;
share: string;
save: string;
read: string;
related: 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-split// 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 post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags,
* figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and
* related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair,
* wide, icons), tone.
*/
import { type ReactNode } from "react";
import { MediaFrame } from "../components/media-frame";
import { PostActions } from "../components/post-actions";
import { PostAuthor } from "../components/post-author";
import { PostOutline } from "../components/post-outline";
import { PostStats } from "../components/post-stats";
import { PostTags } from "../components/post-tags";
import { SectionFrame } from "../components/section-frame";
import type { PostExtras, PostSplitLabels } from "./post-split.types";
import type { Post } from "./post-card.types";
import type { NavLink } from "./nav-bar.types";
export type PostSplitProps = {
id: string;
post: Post;
labels: PostSplitLabels;
extras: PostExtras;
level?: 1 | 2;
layout?: "center" | "split" | "outline";
mediaSide?: "end" | "start";
author?: "line" | "card" | "bio";
cover?: "wide" | "square";
actions?: "pair" | "wide" | "icons";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function PostSplit({
id,
post,
labels,
extras,
level = 1,
layout = "split",
mediaSide = "end",
author = "line",
cover = "wide",
actions = "pair",
tone = "default",
landmarkLabel,
}: PostSplitProps) {
return (
<>
{((layout as string) === "center") ? (
<SectionFrame
id={id}
title={post.title}
lead={post.excerpt}
heading={{ badge: post.category, level }}
tone={tone}
media={{ show: true }}
align="center"
landmarkLabel={landmarkLabel}
aside={(
<MediaFrame
alt={post.title}
src={post.image}
ratio={
(layout as string) === "center" ? "21/9"
: (cover as string) === "square" ? "1/1"
: "4/3"
}
/>
)}
>
{((extras.tags?.length ?? 0) > 0) ? (
<PostTags tags={extras.tags} align="center" />
) : null}
<PostStats post={post} extras={extras} labels={labels} align="center" />
<PostAuthor
post={post}
extras={extras}
labels={labels}
mode="card"
share={true}
className="mx-auto w-full max-w-md"
/>
</SectionFrame>
) : (
<SectionFrame
id={id}
title={post.title}
lead={post.excerpt}
heading={{ badge: post.category, level }}
tone={tone}
media={{ show: true, side: mediaSide }}
layout="split"
landmarkLabel={landmarkLabel}
aside={(
<MediaFrame
alt={post.title}
src={post.image}
ratio={
(layout as string) === "center" ? "21/9"
: (cover as string) === "square" ? "1/1"
: "4/3"
}
/>
)}
>
{((layout as string) === "outline") ? (
<>
{((extras.outline?.length ?? 0) > 0) ? (
<PostOutline post={post} extras={extras} labels={labels} />
) : null}
</>
) : (
<>
<PostAuthor post={post} extras={extras} labels={labels} mode={author} />
{((author as string) !== "line") ? (
<PostStats post={post} extras={extras} labels={labels} />
) : null}
{((extras.tags?.length ?? 0) > 0) ? (
<PostTags tags={extras.tags} />
) : null}
</>
)}
<PostActions labels={labels} mode={actions} />
</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.
import type { NavLink } from "./nav-bar.types";
export type PostExtras = {
role: string;
bio: string;
views: string;
likes: string;
tags: NavLink[];
outline: NavLink[];
};
export type PostSplitLabels = {
minutes: string;
views: string;
likes: string;
share: string;
save: string;
read: string;
related: 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-split// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
import type { NavLink } from "./nav-bar.types";
export type PostExtras = {
role: string;
bio: string;
views: string;
likes: string;
tags: NavLink[];
outline: NavLink[];
};
export type PostSplitLabels = {
minutes: string;
views: string;
likes: string;
share: string;
save: string;
read: string;
related: 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 post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags,
figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and
related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair,
wide, icons), tone.
-->
<script lang="ts">
import type { PostExtras, PostSplitLabels } from "./post-split.types";
import type { Post } from "./post-card.types";
import type { NavLink } from "./nav-bar.types";
export type PostSplitProps = {
id: string;
post: Post;
labels: PostSplitLabels;
extras: PostExtras;
level?: 1 | 2;
layout?: "center" | "split" | "outline";
mediaSide?: "end" | "start";
author?: "line" | "card" | "bio";
cover?: "wide" | "square";
actions?: "pair" | "wide" | "icons";
tone?: "default" | "muted";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import MediaFrame from "../components/media-frame.vue";
import PostActions from "../components/post-actions.vue";
import PostAuthor from "../components/post-author.vue";
import PostOutline from "../components/post-outline.vue";
import PostStats from "../components/post-stats.vue";
import PostTags from "../components/post-tags.vue";
import SectionFrame from "../components/section-frame.vue";
const {
id,
post,
labels,
extras,
level = 1,
layout = "split",
mediaSide = "end",
author = "line",
cover = "wide",
actions = "pair",
tone = "default",
landmarkLabel,
} = defineProps<PostSplitProps>();
</script>
<template>
<SectionFrame v-if="((layout as string) === 'center')"
:id="id"
:title="post.title"
:lead="post.excerpt"
:heading="{ badge: post.category, level }"
:tone="tone"
:media="{ show: true }"
align="center"
:landmarkLabel="landmarkLabel"
>
<PostTags v-if="((extras.tags?.length ?? 0) > 0)" :tags="extras.tags" align="center" />
<PostStats :post="post" :extras="extras" :labels="labels" align="center" />
<PostAuthor
:post="post"
:extras="extras"
:labels="labels"
mode="card"
:share="true"
class="mx-auto w-full max-w-md"
/>
<template #aside>
<MediaFrame
:alt="post.title"
:src="post.image"
:ratio="
(layout as string) === 'center' ? '21/9'
: (cover as string) === 'square' ? '1/1'
: '4/3'
"
/>
</template>
</SectionFrame>
<SectionFrame v-else
:id="id"
:title="post.title"
:lead="post.excerpt"
:heading="{ badge: post.category, level }"
:tone="tone"
:media="{ show: true, side: mediaSide }"
layout="split"
:landmarkLabel="landmarkLabel"
>
<template v-if="((layout as string) === 'outline')">
<PostOutline v-if="((extras.outline?.length ?? 0) > 0)" :post="post" :extras="extras" :labels="labels" />
</template>
<template v-else>
<PostAuthor :post="post" :extras="extras" :labels="labels" :mode="author" />
<PostStats v-if="((author as string) !== 'line')" :post="post" :extras="extras" :labels="labels" />
<PostTags v-if="((extras.tags?.length ?? 0) > 0)" :tags="extras.tags" />
</template>
<PostActions :labels="labels" :mode="actions" />
<template #aside>
<MediaFrame
:alt="post.title"
:src="post.image"
:ratio="
(layout as string) === 'center' ? '21/9'
: (cover as string) === 'square' ? '1/1'
: '4/3'
"
/>
</template>
</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-split// 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 post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags,
* figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and
* related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair,
* wide, icons), tone.
*/
import { type JSX } from "solid-js";
import { MediaFrame } from "../components/media-frame";
import { PostActions } from "../components/post-actions";
import { PostAuthor } from "../components/post-author";
import { PostOutline } from "../components/post-outline";
import { PostStats } from "../components/post-stats";
import { PostTags } from "../components/post-tags";
import { SectionFrame } from "../components/section-frame";
import type { PostExtras, PostSplitLabels } from "./post-split.types";
import type { Post } from "./post-card.types";
import type { NavLink } from "./nav-bar.types";
export type PostSplitProps = {
id: string;
post: Post;
labels: PostSplitLabels;
extras: PostExtras;
level?: 1 | 2;
layout?: "center" | "split" | "outline";
mediaSide?: "end" | "start";
author?: "line" | "card" | "bio";
cover?: "wide" | "square";
actions?: "pair" | "wide" | "icons";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function PostSplit({
id,
post,
labels,
extras,
level = 1,
layout = "split",
mediaSide = "end",
author = "line",
cover = "wide",
actions = "pair",
tone = "default",
landmarkLabel,
}: PostSplitProps) {
return (
<>
{((layout as string) === "center") ? (
<SectionFrame
id={id}
title={post.title}
lead={post.excerpt}
heading={{ badge: post.category, level }}
tone={tone}
media={{ show: true }}
align="center"
landmarkLabel={landmarkLabel}
aside={(
<MediaFrame
alt={post.title}
src={post.image}
ratio={
(layout as string) === "center" ? "21/9"
: (cover as string) === "square" ? "1/1"
: "4/3"
}
/>
)}
>
{((extras.tags?.length ?? 0) > 0) ? (
<PostTags tags={extras.tags} align="center" />
) : null}
<PostStats post={post} extras={extras} labels={labels} align="center" />
<PostAuthor
post={post}
extras={extras}
labels={labels}
mode="card"
share={true}
class="mx-auto w-full max-w-md"
/>
</SectionFrame>
) : (
<SectionFrame
id={id}
title={post.title}
lead={post.excerpt}
heading={{ badge: post.category, level }}
tone={tone}
media={{ show: true, side: mediaSide }}
layout="split"
landmarkLabel={landmarkLabel}
aside={(
<MediaFrame
alt={post.title}
src={post.image}
ratio={
(layout as string) === "center" ? "21/9"
: (cover as string) === "square" ? "1/1"
: "4/3"
}
/>
)}
>
{((layout as string) === "outline") ? (
<>
{((extras.outline?.length ?? 0) > 0) ? (
<PostOutline post={post} extras={extras} labels={labels} />
) : null}
</>
) : (
<>
<PostAuthor post={post} extras={extras} labels={labels} mode={author} />
{((author as string) !== "line") ? (
<PostStats post={post} extras={extras} labels={labels} />
) : null}
{((extras.tags?.length ?? 0) > 0) ? (
<PostTags tags={extras.tags} />
) : null}
</>
)}
<PostActions labels={labels} mode={actions} />
</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.
import type { NavLink } from "./nav-bar.types";
export type PostExtras = {
role: string;
bio: string;
views: string;
likes: string;
tags: NavLink[];
outline: NavLink[];
};
export type PostSplitLabels = {
minutes: string;
views: string;
likes: string;
share: string;
save: string;
read: string;
related: 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-split// 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-split.json
package blocks
import (
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// PostSplitProps are the props of PostSplit; the values are the JSON shapes of the TypeScript props.
type PostSplitProps struct {
Id any `json:"id"`
Post any `json:"post"`
Labels any `json:"labels"`
Extras any `json:"extras"`
Level any `json:"level"`
Layout any `json:"layout"`
MediaSide any `json:"mediaSide"`
Author any `json:"author"`
Cover any `json:"cover"`
Actions any `json:"actions"`
Tone any `json:"tone"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags, figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair, wide, icons), tone.
templ PostSplit(p PostSplitProps) {
{{ vId := p.Id }}
{{ vPost := p.Post }}
{{ vLabels := p.Labels }}
{{ vExtras := p.Extras }}
{{ vLevel := uiutils.Def(p.Level, float64(1)) }}
{{ vLayout := uiutils.Def(p.Layout, "split") }}
{{ vMediaSide := uiutils.Def(p.MediaSide, "end") }}
{{ vAuthor := uiutils.Def(p.Author, "line") }}
{{ vCover := uiutils.Def(p.Cover, "wide") }}
{{ vActions := uiutils.Def(p.Actions, "pair") }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
if uiutils.Eq(vLayout, "center") {
@SectionFrame(SectionFrameProps{Id: vId, Title: uiutils.Get(vPost, "title"), Lead: uiutils.Get(vPost, "excerpt"), Heading: map[string]any{"badge": uiutils.Get(vPost, "category"), "level": vLevel}, Tone: vTone, Media: map[string]any{"show": true}, Align: "center", LandmarkLabel: vLandmarkLabel, Aside: postSplitFill1(p, vPost, vLayout, vCover)}) {
if uiutils.Gt(uiutils.Len(uiutils.Get(vExtras, "tags")), float64(0)) {
@PostTags(PostTagsProps{Tags: uiutils.Get(vExtras, "tags"), Align: "center"})
}
@PostStats(PostStatsProps{Post: vPost, Extras: vExtras, Labels: vLabels, Align: "center"})
@PostAuthor(PostAuthorProps{Post: vPost, Extras: vExtras, Labels: vLabels, Mode: "card", Share: true, Class: uiutils.Cnv("mx-auto w-full max-w-md")})
}
} else {
@SectionFrame(SectionFrameProps{Id: vId, Title: uiutils.Get(vPost, "title"), Lead: uiutils.Get(vPost, "excerpt"), Heading: map[string]any{"badge": uiutils.Get(vPost, "category"), "level": vLevel}, Tone: vTone, Media: map[string]any{"show": true, "side": vMediaSide}, Layout: "split", LandmarkLabel: vLandmarkLabel, Aside: postSplitFill2(p, vPost, vLayout, vCover)}) {
if uiutils.Eq(vLayout, "outline") {
if uiutils.Gt(uiutils.Len(uiutils.Get(vExtras, "outline")), float64(0)) {
@PostOutline(PostOutlineProps{Post: vPost, Extras: vExtras, Labels: vLabels})
}
} else {
@PostAuthor(PostAuthorProps{Post: vPost, Extras: vExtras, Labels: vLabels, Mode: vAuthor})
if !uiutils.Eq(vAuthor, "line") {
@PostStats(PostStatsProps{Post: vPost, Extras: vExtras, Labels: vLabels})
}
if uiutils.Gt(uiutils.Len(uiutils.Get(vExtras, "tags")), float64(0)) {
@PostTags(PostTagsProps{Tags: uiutils.Get(vExtras, "tags")})
}
}
@PostActions(PostActionsProps{Labels: vLabels, Mode: vActions})
}
}
}
templ postSplitFill1(p PostSplitProps, vPost any, vLayout any, vCover any) {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vPost, "title"), Src: uiutils.Get(vPost, "image"), Ratio: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "center")), "21/9", uiutils.Cond(uiutils.T(uiutils.Eq(vCover, "square")), "1/1", "4/3"))})
}
templ postSplitFill2(p PostSplitProps, vPost any, vLayout any, vCover any) {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vPost, "title"), Src: uiutils.Get(vPost, "image"), Ratio: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "center")), "21/9", uiutils.Cond(uiutils.T(uiutils.Eq(vCover, "square")), "1/1", "4/3"))})
}
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-split{#- 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-split.json
A post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags, figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair, wide, icons), tone.
Props (p): id, post, labels, extras, level, layout, mediaSide, author, cover, actions, tone, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_post = (p.post ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_extras = (p.extras ?? null) -%}
{%- set v_level = (p.level ?? 1) -%}
{%- set v_layout = (p.layout ?? 'split') -%}
{%- set v_mediaSide = (p.mediaSide ?? 'end') -%}
{%- set v_author = (p.author ?? 'line') -%}
{%- set v_cover = (p.cover ?? 'wide') -%}
{%- set v_actions = (p.actions ?? 'pair') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- if og_t(og_eq(v_layout, 'center')) %}
{%- set f_1 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_post, ['title']), 'src': og_get(v_post, ['image']), 'ratio': (og_t(og_eq(v_layout, 'center')) ? '21/9' : (og_t(og_eq(v_cover, 'square')) ? '1/1' : '4/3'))}}, with_context = false) }}
{%- endset -%}
{%- set c_2 -%}
{%- if og_t(og_gt(og_len(og_get(v_extras, ['tags'])), 0)) %}
{{ include('blocks/post-tags.html.twig', {'p': {'tags': og_get(v_extras, ['tags']), 'align': 'center'}}, with_context = false) }}
{%- endif %}
{{ include('blocks/post-stats.html.twig', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels, 'align': 'center'}}, with_context = false) }}
{{ include('blocks/post-author.html.twig', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels, 'mode': 'card', 'share': true, 'className': og_cnv(['mx-auto w-full max-w-md'])}}, with_context = false) }}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': og_get(v_post, ['title']), 'lead': og_get(v_post, ['excerpt']), 'heading': {'badge': og_get(v_post, ['category']), 'level': v_level}, 'tone': v_tone, 'media': {'show': true}, 'align': 'center', 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_1)}, 'children': og_markup(c_2)}, with_context = false) }}
{%- else %}
{%- set f_3 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_post, ['title']), 'src': og_get(v_post, ['image']), 'ratio': (og_t(og_eq(v_layout, 'center')) ? '21/9' : (og_t(og_eq(v_cover, 'square')) ? '1/1' : '4/3'))}}, with_context = false) }}
{%- endset -%}
{%- set c_4 -%}
{%- if og_t(og_eq(v_layout, 'outline')) %}
{%- if og_t(og_gt(og_len(og_get(v_extras, ['outline'])), 0)) %}
{{ include('blocks/post-outline.html.twig', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels}}, with_context = false) }}
{%- endif %}
{%- else %}
{{ include('blocks/post-author.html.twig', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels, 'mode': v_author}}, with_context = false) }}
{%- if og_t(not (og_eq(v_author, 'line'))) %}
{{ include('blocks/post-stats.html.twig', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels}}, with_context = false) }}
{%- endif %}
{%- if og_t(og_gt(og_len(og_get(v_extras, ['tags'])), 0)) %}
{{ include('blocks/post-tags.html.twig', {'p': {'tags': og_get(v_extras, ['tags'])}}, with_context = false) }}
{%- endif %}
{%- endif %}
{{ include('blocks/post-actions.html.twig', {'p': {'labels': v_labels, 'mode': v_actions}}, with_context = false) }}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': og_get(v_post, ['title']), 'lead': og_get(v_post, ['excerpt']), 'heading': {'badge': og_get(v_post, ['category']), 'level': v_level}, 'tone': v_tone, 'media': {'show': true, 'side': v_mediaSide}, 'layout': 'split', 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_3)}, 'children': og_markup(c_4)}, with_context = false) }}
{%- endif %}
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-split{* 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-split.json
A post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags, figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair, wide, icons), tone.
Props (p): id, post, labels, extras, level, layout, mediaSide, author, cover, actions, tone, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_post = ($p['post'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_extras = ($p['extras'] ?? null)}
{var $v_level = ($p['level'] ?? 1)}
{var $v_layout = ($p['layout'] ?? 'split')}
{var $v_mediaSide = ($p['mediaSide'] ?? 'end')}
{var $v_author = ($p['author'] ?? 'line')}
{var $v_cover = ($p['cover'] ?? 'wide')}
{var $v_actions = ($p['actions'] ?? 'pair')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{if og_t(og_eq($v_layout, 'center'))}
{capture $f_1}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_post, ['title']), 'src' => og_get($v_post, ['image']), 'ratio' => (og_t(og_eq($v_layout, 'center')) ? '21/9' : (og_t(og_eq($v_cover, 'square')) ? '1/1' : '4/3'))]])|noescape}
{/capture}
{capture $c_2}
{if og_t(og_gt(og_len(og_get($v_extras, ['tags'])), 0))}
{=og_include('blocks/post-tags.latte', ['p' => ['tags' => og_get($v_extras, ['tags']), 'align' => 'center']])|noescape}
{/if}
{=og_include('blocks/post-stats.latte', ['p' => ['post' => $v_post, 'extras' => $v_extras, 'labels' => $v_labels, 'align' => 'center']])|noescape}
{=og_include('blocks/post-author.latte', ['p' => ['post' => $v_post, 'extras' => $v_extras, 'labels' => $v_labels, 'mode' => 'card', 'share' => true, 'className' => og_cnv(['mx-auto w-full max-w-md'])]])|noescape}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => og_get($v_post, ['title']), 'lead' => og_get($v_post, ['excerpt']), 'heading' => ['badge' => og_get($v_post, ['category']), 'level' => $v_level], 'tone' => $v_tone, 'media' => ['show' => true], 'align' => 'center', 'landmarkLabel' => $v_landmarkLabel, 'aside' => og_markup($f_1)], 'children' => og_markup($c_2)])|noescape}
{else}
{capture $f_3}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_post, ['title']), 'src' => og_get($v_post, ['image']), 'ratio' => (og_t(og_eq($v_layout, 'center')) ? '21/9' : (og_t(og_eq($v_cover, 'square')) ? '1/1' : '4/3'))]])|noescape}
{/capture}
{capture $c_4}
{if og_t(og_eq($v_layout, 'outline'))}
{if og_t(og_gt(og_len(og_get($v_extras, ['outline'])), 0))}
{=og_include('blocks/post-outline.latte', ['p' => ['post' => $v_post, 'extras' => $v_extras, 'labels' => $v_labels]])|noescape}
{/if}
{else}
{=og_include('blocks/post-author.latte', ['p' => ['post' => $v_post, 'extras' => $v_extras, 'labels' => $v_labels, 'mode' => $v_author]])|noescape}
{if og_t(!(og_eq($v_author, 'line')))}
{=og_include('blocks/post-stats.latte', ['p' => ['post' => $v_post, 'extras' => $v_extras, 'labels' => $v_labels]])|noescape}
{/if}
{if og_t(og_gt(og_len(og_get($v_extras, ['tags'])), 0))}
{=og_include('blocks/post-tags.latte', ['p' => ['tags' => og_get($v_extras, ['tags'])]])|noescape}
{/if}
{/if}
{=og_include('blocks/post-actions.latte', ['p' => ['labels' => $v_labels, 'mode' => $v_actions]])|noescape}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => og_get($v_post, ['title']), 'lead' => og_get($v_post, ['excerpt']), 'heading' => ['badge' => og_get($v_post, ['category']), 'level' => $v_level], 'tone' => $v_tone, 'media' => ['show' => true, 'side' => $v_mediaSide], 'layout' => 'split', 'landmarkLabel' => $v_landmarkLabel, 'aside' => og_markup($f_3)], 'children' => og_markup($c_4)])|noescape}
{/if}
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-split{#- 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-split.json
A post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags, figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair, wide, icons), tone.
Props (p): id, post, labels, extras, level, layout, mediaSide, author, cover, actions, tone, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_post = og_def(p['post'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_extras = og_def(p['extras'], none) -%}
{%- set v_level = og_def(p['level'], 1) -%}
{%- set v_layout = og_def(p['layout'], 'split') -%}
{%- set v_mediaSide = og_def(p['mediaSide'], 'end') -%}
{%- set v_author = og_def(p['author'], 'line') -%}
{%- set v_cover = og_def(p['cover'], 'wide') -%}
{%- set v_actions = og_def(p['actions'], 'pair') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- if og_t(og_eq(v_layout, 'center')) %}
{%- set f_1 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_post, ['title']), 'src': og_get(v_post, ['image']), 'ratio': ('21/9' if og_t(og_eq(v_layout, 'center')) else ('1/1' if og_t(og_eq(v_cover, 'square')) else '4/3'))}}) }}
{%- endset -%}
{%- set c_2 -%}
{%- if og_t(og_gt(og_len(og_get(v_extras, ['tags'])), 0)) %}
{{ og_include('blocks/post-tags.html.j2', {'p': {'tags': og_get(v_extras, ['tags']), 'align': 'center'}}) }}
{%- endif %}
{{ og_include('blocks/post-stats.html.j2', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels, 'align': 'center'}}) }}
{{ og_include('blocks/post-author.html.j2', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels, 'mode': 'card', 'share': true, 'className': og_cnv(['mx-auto w-full max-w-md'])}}) }}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': og_get(v_post, ['title']), 'lead': og_get(v_post, ['excerpt']), 'heading': {'badge': og_get(v_post, ['category']), 'level': v_level}, 'tone': v_tone, 'media': {'show': true}, 'align': 'center', 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_1)}, 'children': og_markup(c_2)}) }}
{%- else %}
{%- set f_3 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_post, ['title']), 'src': og_get(v_post, ['image']), 'ratio': ('21/9' if og_t(og_eq(v_layout, 'center')) else ('1/1' if og_t(og_eq(v_cover, 'square')) else '4/3'))}}) }}
{%- endset -%}
{%- set c_4 -%}
{%- if og_t(og_eq(v_layout, 'outline')) %}
{%- if og_t(og_gt(og_len(og_get(v_extras, ['outline'])), 0)) %}
{{ og_include('blocks/post-outline.html.j2', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels}}) }}
{%- endif %}
{%- else %}
{{ og_include('blocks/post-author.html.j2', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels, 'mode': v_author}}) }}
{%- if og_t(not (og_eq(v_author, 'line'))) %}
{{ og_include('blocks/post-stats.html.j2', {'p': {'post': v_post, 'extras': v_extras, 'labels': v_labels}}) }}
{%- endif %}
{%- if og_t(og_gt(og_len(og_get(v_extras, ['tags'])), 0)) %}
{{ og_include('blocks/post-tags.html.j2', {'p': {'tags': og_get(v_extras, ['tags'])}}) }}
{%- endif %}
{%- endif %}
{{ og_include('blocks/post-actions.html.j2', {'p': {'labels': v_labels, 'mode': v_actions}}) }}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': og_get(v_post, ['title']), 'lead': og_get(v_post, ['excerpt']), 'heading': {'badge': og_get(v_post, ['category']), 'level': v_level}, 'tone': v_tone, 'media': {'show': true, 'side': v_mediaSide}, 'layout': 'split', 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_3)}, 'children': og_markup(c_4)}) }}
{%- endif %}
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 post header with the author, the reading figures, the tags and the actions. Axes: layout (center: tags, figures and an author card with share and save over a wide cover; split: beside the cover; outline: facts and related reading beside the cover), mediaSide, author (line, card, bio), cover (wide, square), actions (pair, wide, icons), tone.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| post (required) | Post | - | |
| labels (required) | PostSplitLabels | - | templates: minutes `{0} min read`, views `{0} views`, likes `{0} likes`; the words of the buttons and of the related heading |
| extras (required) | PostExtras | - | |
| level | 1 | 2 | 1 | |
| layout | "center" | "split" | "outline" | "split" | |
| mediaSide | "end" | "start" | "end" | |
| author | "line" | "card" | "bio" | "line" | |
| cover | "wide" | "square" | "wide" | |
| actions | "pair" | "wide" | "icons" | "pair" | |
| tone | "default" | "muted" | "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 |