ProseItem

apps/www/src/sections/ProseItem.astro · 42 lines · group Text & prose

ProseItem — a titled sub-section inside <Prose>: a subheading, markdown, an optional picture and an optional button. Several of them stack inside ONE section with a normal vertical rhythm. Use for: an "about" page with three themes, a certification page with one block per certificate, a services description — anything that would otherwise become a run of separate sections. Parent: <Prose> only (usually <Prose heading="left">). Children: markdown between the tags. Picture: `image` (file name in images/) is shown under the text of this item.

In the fleet

Used on 1 site built with this engine.

Samples 1

sampleshown inside <Prose>

How a season is put together

Before the season

Stations go up while the ground is still hard: one bolt, one scan, and the thresholds from last year are already there.

During the season

The dashboard is quiet on purpose. It speaks when a field crosses a line you drew, and stays out of the way otherwise.

After the harvest

The season is exported in one click and compared with the ones before it. The stations stay where they are.

MDX of this sample
<Prose title="How a season is put together" heading="left">
  <ProseItem title="Before the season">
Stations go up while the ground is still hard: one bolt, one scan, and the thresholds from last year are already there.
  </ProseItem>
  <ProseItem title="During the season">
The dashboard is quiet on purpose. It speaks when a field crosses a line you drew, and stays out of the way otherwise.
  </ProseItem>
  <ProseItem title="After the harvest">
The season is exported in one click and compared with the ones before it. The stations stay where they are.
  </ProseItem>
</Prose>

Props

NameTypeRequiredDefaultDescription
titlestringthe subheading
imagestringfile name in images/, shown under the text
linkTextstringtext of a button under the item; shown only with href
hrefstringlink of that button

Source apps/www/src/sections/ProseItem.astro @ gitt.one

---
/**
 * ProseItem — a titled sub-section inside <Prose>: a subheading, markdown, an
 *   optional picture and an optional button. Several of them stack inside ONE
 *   section with a normal vertical rhythm.
 *
 * Use for: an "about" page with three themes, a certification page with one
 *   block per certificate, a services description — anything that would
 *   otherwise become a run of separate sections.
 * Parent: <Prose> only (usually <Prose heading="left">).
 * Children: markdown between the tags.
 * Picture: `image` (file name in images/) is shown under the text of this
 *   item.
 */
import { Image } from 'astro:assets';
import { resolveImage } from '../lib/images';
import Button from './_Button.astro';

interface Props {
  /** the subheading */
  title?: string;
  /** file name in images/, shown under the text */
  image?: string;
  /** text of a button under the item; shown only with href */
  linkText?: string;
  /** link of that button */
  href?: string;
}

const { title, image, linkText, href } = Astro.props;
const img = image ? await resolveImage(image) : undefined;
---

<article class="not-prose mt-10 first:mt-0">
  {title && <h3 class="text-xl font-bold tracking-tight text-gray-900 sm:text-2xl [.bg-stone-800_&]:text-white">{title}</h3>}
  <div class="prose prose-gray mt-3 max-w-none text-gray-500 [.bg-stone-800_&]:text-gray-300">
    <slot />
  </div>
  {img && <Image src={img} alt={title ?? ''} widths={[400, 840]} class="mt-6 w-full max-w-2xl rounded-lg shadow-lg" />}
  {linkText && href && <p class="mt-6"><Button href={href}>{linkText}</Button></p>}
</article>

Source links point to engine-astro@7b686388. Samples are demo content: the components are the real ones, the copy and the pictures are made up.