Skip to content

struct

Route

pub struct Route {
    pub pattern: &'static str,
    pub page: &'static str,
    pub meta: &'static [(&'static str, &'static str)],
    pub static_params: Option<fn() -> Vec<Params>>,
    pub interactive: Option<bool>,
    pub title: Option<fn(&Params) -> Option<String>>,
}

One page of an app.

Fields

pattern

pub pattern: &'static str

/, /about/, /blog/:slug/, /docs/*path/.

page

pub page: &'static str

The page's component name.

meta

pub meta: &'static [(&'static str, &'static str)]

The page's metadata (its layouts', then its own, which win): title, description. Values may interpolate {params.x}.

static_params

pub static_params: Option<fn() -> Vec<Params>>

The parameter sets to prerender a dynamic route with.

interactive

pub interactive: Option<bool>

Overrides whether the page needs the runtime (wasm) in the browser.

title

pub title: Option<fn(&Params) -> Option<String>>

The page's title from its companion (pub fn title(params)), for titles meta can't spell, such as a post's.

Methods

is_dynamic

pub fn is_dynamic(&self) -> bool

Whether the pattern has parameters.

path_for

pub fn path_for(&self, params: &Params) -> String

The pattern with params filled in (/blog/hello/).

meta_value

pub fn meta_value(&self, key: &str, params: &Params) -> Option<String>

A metadata value with {params.x} filled in.

Trait implementations