Skip to content
Klarhimmel UI

Blog, post

Blog, post previewBlog, post preview

Install

npx shadcn add @klarhimmel/blog-post
DetailsAbout, usage, props and more

An article: category, title, date and reading time, author, cover image and a reading column of body text.

Import

Import

import Block from '@/components/klarhimmel/blocks/blog-post';
Also called
  • blog/post
Category
Post cards, lists and the article page. New project? Set it up once: /get-started/installation.

Notes

When to use it

A single article page: category and date, title, author, cover image and a reading column of body text. It is the article itself, so use blog-list or blog-cards for index pages.

Writing for it

- The title is the page's h1 and holds 140 characters. State the finding in it, because there is no separate intro field. - The body takes 4000 characters as plain text. Separate paragraphs with a blank line, since line breaks are kept as written. - Fill the author role (80 characters) with a job and a company, as the default does. It sits under the name beside a small round photo.

Watch out for

The title renders as an h1, so do not place another h1 block such as a hero on the same page. The body has no headings, lists, links or images, only paragraphs of text, so a long how-to needs another format.

Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import BlogPost from '@/components/klarhimmel/blocks/blog-post';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <BlogPost props={{
          "category": "Category",
          "title": "Say what the post is about, as a title",
          "meta": "1 Jan 0000 · 0 min read",
          "author": {
            "name": "Name a person",
            "role": "Their role and company",
            "photo": {
              "src": "/pictures/avatar-4.svg",
              "alt": "A portrait of a person",
              "srcDark": "/pictures/avatar-4-dark.svg"
            }
          },
          "cover": {
            "src": "/pictures/photo-bakery1.avif",
            "alt": "A bakery counter with loaves and pastries behind glass"
          },
          "body": "Open with the problem the reader knows well, and say plainly why it matters to them and what usually goes wrong.\n\nGive the way you do it, in two or three plain sentences, with the steps in the order they happen and the one question that guides each.\n\nSay one practical thing they can do before they start, and why it matters more than it seems to.\n\nClose with a short line that leaves them with one thing to remember, and an invitation if there is one."
        }} />
      </BlockSurface>
    </Theme>
  );
}

Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

PropTypeDefaultDescription
categorystring'Category'Text, up to 30 characters.
titlestring'Say what the post is about, as a ti…'Text, up to 140 characters.
metastring'1 Jan 0000 · 0 min read'Text, up to 80 characters.
author{ name, role, photo }{…}Fields: name, role, photo.
coverMedia{…}See the type.
bodystring'Open with the problem the reader kn…'Markdown prose: paragraphs separated by blank lines, ## section headings, ### subheadings, bullet lists, bold, code, links (https or the site's own /pages) and a paragraph that is only ![alt](src) as a picture. Raw HTML stays text. Text, up to 12000 characters.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.