Skip to main content

Shortcode

Enum Shortcode 

Source
pub enum Shortcode {
    Subscribe(SubscribeShortcode),
    Buttons(ButtonsShortcode),
    Gallery(GalleryShortcode),
    Hero(HeroShortcode),
    Grid(GridShortcode),
    Recent(RecentShortcode),
    Apply(ApplyShortcode),
}
Expand description

A typed shortcode block.

Variants:

Phase B migrations add one variant per commit.

Variants§

§

Subscribe(SubscribeShortcode)

:::subscribe — inline newsletter signup form.

Configuration is via attributes (placeholder, button); body must be empty under the unified grammar. Description text and any framing prose live in the surrounding markdown.

§

Buttons(ButtonsShortcode)

:::buttons {.classname} — list of action buttons.

Body is one markdown link per line ([text](url)). The first button gets the primary class; subsequent buttons get secondary. Optional {.classname} extra classes attach to the wrapping div.

URLs flow through Url::Unresolved at parse time; crate::ast::visit::visit_urls_mut (or src-tauri’s apply_typed_shortcodes) classifies them into Url::Resolved before rendering. The resolver-bypass class is closed by construction: RenderHooks::render_shortcode reads Url::Resolved, so a missing visitor is a debug-time crash.

§

Gallery(GalleryShortcode)

:::gallery N {.classname} — image gallery with optional columns.

N (positional integer) sets --moss-gallery-columns CSS variable. Body is one image reference per line: ![alt](path), bare path.jpg, or path|attrs for media attributes (passed through to the renderer’s inline style).

§

Hero(HeroShortcode)

:::hero {image=path} — full-width hero section with media + overlay.

New grammar: image attribute carries the path. Backward-compat: when image is absent, the extractor scans the first non-empty body line for a media reference (![[path]], ![alt](path), or bare media filename).

The pipeline hoists the rendered hero HTML into the article template’s hero slot — it does NOT render inline.

§

Grid(GridShortcode)

:::grid {cols=N} or :::grid N — flexible multi-cell layout.

Cells are split on +++ (new grammar) or --- (legacy moss-releases backward-compat — Step 3 of #613 rewrites these to +++). Each cell stores its raw markdown source; the renderer is responsible for any nested-shortcode extraction and markdown processing per cell.

§

Recent(RecentShortcode)

:::recent since=... last=... count=... — list of recent posts scoped to the page’s top-level folder (its scope).

Body (between the opening and closing :::) is reserved for fallback content rendered when the query returns zero matches. Empty body means no fallback (the shortcode renders nothing).

§

Apply(ApplyShortcode)

:::apply — inline membership/contributor application form.

Posts to the moss-seta /apply endpoint with fields email, matters, publish, scope, and website (honeypot). Configuration is via attributes (placeholder, button); body must be empty. One-of {matters, publish} is server-enforced. Succeeds terminally (no auto-revert) via data-revert="false".

Implementations§

Source§

impl Shortcode

Source

pub fn kind(&self) -> ShortcodeKind

Return the ShortcodeKind of this shortcode.

Trait Implementations§

Source§

impl Clone for Shortcode

Source§

fn clone(&self) -> Shortcode

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 Shortcode

Source§

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

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

impl<'de> Deserialize<'de> for Shortcode

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 Shortcode

Source§

impl PartialEq for Shortcode

Source§

fn eq(&self, other: &Shortcode) -> 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 Shortcode

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 Shortcode

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.