// @generated by ferrovue from client/pages/picks.vue. Do not edit: change the `.vue` file and run // `ferrovue`. use std::borrow::Cow; use ferrovue as fv; /// The component's name, as `data-island` carries it. pub const NAME: &str = "Picks"; /// The props `picks.vue` declares. #[derive(Debug, Clone, serde::Serialize)] #[cfg_attr(test, derive(serde::Deserialize))] pub struct Props<'a> { pub shop: Cow<'a, str>, pub featured: super::types::Book<'a>, pub books: Vec>, } impl<'a> Props<'a> { /// Props with its required fields. pub fn new(shop: impl Into>, featured: super::types::Book<'a>, books: Vec>) -> Self { Props { shop: shop.into(), featured, books } } } /// What a parent puts in the slots `picks.vue` renders. #[derive(Clone, Copy, Default)] pub struct Slots<'s> { /// `` pub default: Option>, /// `` pub reviews: Option>, } /// Write the component's server render into `out`. /// /// # Panics /// /// With the message of the refusal [`try_render`] returns. pub fn render(out: &mut String, props: &Props<'_>, fv_slots: Slots<'_>, fv_route: &fv::router::Route<'_>, fv_head: &fv::head::Head, fv_loads: &fv::loaders::Loads<'_>) { fv::render::rendered(try_render(out, props, fv_slots, fv_route, fv_head, fv_loads)); } /// [`render`], returning the refusal of a render that cannot write what Vue writes for these /// props, such as a date string browsers read differently: a server answers it with an error. /// /// # Errors /// /// The first [`fv::render::Refused`] the render met; `out` then holds what was written before it. pub fn try_render(out: &mut String, props: &Props<'_>, fv_slots: Slots<'_>, fv_route: &fv::router::Route<'_>, fv_head: &fv::head::Head, fv_loads: &fv::loaders::Loads<'_>) -> Result<(), fv::render::Refused> { out.reserve( 393 + 44 * props.books.len() + props.shop.len() + props.featured.id.len() + props.featured.title.len() + props.featured.author.len() + props.books.iter().map(|v| v.id.len() + v.title.len() + v.author.len()).sum::() ); fv_head.push(fv::head::HeadValue::object([ ("title", fv::head::HeadValue::str(&format!("Staff picks · {}", props.shop))), ("meta", fv::head::HeadValue::array([fv::head::HeadValue::object([ ("name", fv::head::HeadValue::str("description")), ("content", fv::head::HeadValue::str(&format!("{} and the rest of this week's staff picks", props.featured.title))), ])])), ("htmlAttrs", fv::head::HeadValue::object([("class", fv::head::HeadValue::str("picks-page"))])), ])); out.push_str("
"); fv::attrs::link_named_open(out, fv_route, "/", &[], "", "", "page", "", "active", &["brand"], true); out.push('>'); fv::core::escape_into(out, &props.shop); out.push_str("
"); fv::render::slot_into(out, fv_slots.default, None); out.push_str("
One app: the layout and every part in it, hydrated from the record the server wrote.
"); Ok(()) } /// The component's markup, for a maud page that shows it. pub fn html<'p, 'a>(props: &'p Props<'a>, fv_slots: Slots<'p>, fv_route: &'p fv::router::Route<'p>, fv_head: &'p fv::head::Head, fv_loads: &'p fv::loaders::Loads<'p>) -> fv::html::Html<'p, Props<'a>, impl fv::html::Renderer> + 'p> { fv::html::Html::markup(props, fv::html::Fallible(move |out: &mut String, props: &Props<'a>| try_render(out, props, fv_slots, fv_route, fv_head, fv_loads))) }