Skip to main content

HeroShortcode

Struct HeroShortcode 

Source
pub struct HeroShortcode {
    pub image: Option<Url>,
    pub extra_images: Vec<Url>,
    pub attrs: String,
    pub classes: String,
    pub overlay: Vec<Block>,
    pub overlay_text: String,
    pub width: Option<String>,
    pub mobile: Option<String>,
    pub caption: String,
}
Expand description

Arguments for Shortcode::Hero.

Fields§

§image: Option<Url>

Primary image source URL. None if neither the image attribute nor a leading body media line provided one — the renderer emits a section with no <img> in that case. Flows through resolver before rendering. With extra_images, this is the first slide and the reduced-motion/static fallback.

§extra_images: Vec<Url>

Remaining background slides (2026-07-27 multi-image hero): every consecutive leading body media line after the first. Non-empty → the hero renders an ambient crossfade (one slide visible at a time, no controls — no slide may carry information the others don’t; design: docs/archive/2026-07-27-import-conventions-engine-design.md). Empty for image=-attribute and directive-line heroes.

§attrs: String

Pipe-suffix media attributes verbatim (e.g. “cover top”, “1.5:1 contain”). Empty if no pipe in the source.

§classes: String

Extra CSS classes for the wrapping <section> (from {.foo .bar}).

§overlay: Vec<Block>

Parsed block content for the overlay. Phase 4 PR4.5 (2026-05-28) promoted this from overlay_markdown: String to overlay: Vec<Block> (fully-typed AST). Nested shortcodes inside the overlay (::::buttons inside :::hero) extract through crate::ast::parser::parse recursion in [crate::ast::shortcode_extract::parse_hero].

§overlay_text: String

Plain-text overlay source for downstream OG-fallback extraction.

PR4.5 (2026-05-28): captured at parse time alongside the typed overlay because crate::build::page::meta::extract_description (the homepage-hero rung in the description chain) operates on markdown source — round-tripping Vec<Block> to markdown would invite drift. The renderer uses overlay for HTML; downstream consumers read overlay_text for description-chain extraction.

Empty when the author wrote no overlay body.

TODO(phase4-cleanup): replace with a Vec-walking to_plain_text(blocks: &[Block]) -> String helper in moss-core

  • consume overlay directly in meta.rs::extract_description, deleting this field. Carrying both overlay: Vec<Block> AND overlay_text: String makes the AST non-canonical (which is the source of truth?); per cross-SSG research, lossy or duplicate state is Gatsby’s mistake. This is transitional — flag if it survives past PR7a. (Architecture review caveat 2026-05-28.)
§width: Option<String>

Spec § P9 width attribute: body | wide | page | screen (with full aliased to screen). None means the author did not set a width — the emitter omits data-width so the HTML stays sparse.

§mobile: Option<String>

Mobile layout override. Some("overlay") keeps text overlaid on a taller cropped image on mobile. None = default stacking behavior (image full-width at natural ratio, text block below).

§caption: String

Caption or credit for the image, from caption="…". Rendered as a line of text BELOW the hero, never over it.

The overlay and the caption answer different questions. The overlay is text laid on the photograph — a title, a standfirst — and it is styled to be read against the image. A caption says what the photograph is and who took it, and printing that across someone’s picture is both unreadable and, for a credit, wrong: a photographer’s name has to survive as text, not as part of the composition. So a hero carrying a cover credit («封面:…(拍攝:…)») has somewhere to put it that is not on top of the subject.

A display string, rendered as inline markdown by the host — the same treatment byline: / colophon: rows get — so a credit can be a link. Empty when the author wrote no caption.

Trait Implementations§

Source§

impl Clone for HeroShortcode

Source§

fn clone(&self) -> HeroShortcode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HeroShortcode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HeroShortcode

Source§

fn default() -> HeroShortcode

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for HeroShortcode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for HeroShortcode

Source§

impl PartialEq for HeroShortcode

Source§

fn eq(&self, other: &HeroShortcode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for HeroShortcode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for HeroShortcode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.