pub struct Metadata {Show 22 fields
pub title: Option<String>,
pub title_template: Option<String>,
pub title_absolute: bool,
pub description: Option<String>,
pub keywords: Option<Vec<String>>,
pub authors: Option<Vec<String>>,
pub canonical: Option<String>,
pub robots: Option<String>,
pub viewport: Option<String>,
pub theme_color: Option<String>,
pub color_scheme: Option<String>,
pub manifest: Option<String>,
pub icons: Option<Vec<Icon>>,
pub open_graph: Option<OpenGraph>,
pub twitter: Option<Twitter>,
pub alternates: Option<Vec<(String, String)>>,
pub other: Vec<(String, String)>,
pub stylesheets: Vec<String>,
pub preloads: Vec<Preload>,
pub links: Vec<LinkTag>,
pub html_attributes: Vec<(String, String)>,
pub theme_colors: Vec<(String, String)>,
}Fields§
§title: Option<String>§title_template: Option<String>Applied to descendant titles; %s is replaced by the child title.
title_absolute: boolWhen true, this title ignores ancestor templates.
description: Option<String>§keywords: Option<Vec<String>>§canonical: Option<String>§robots: Option<String>§viewport: Option<String>§theme_color: Option<String>§color_scheme: Option<String>§manifest: Option<String>§icons: Option<Vec<Icon>>§open_graph: Option<OpenGraph>§twitter: Option<Twitter>§alternates: Option<Vec<(String, String)>>hreflang alternates: (language, url).
other: Vec<(String, String)>Extra <meta name=.. content=..> entries.
stylesheets: Vec<String>External stylesheets (<link rel="stylesheet">).
preloads: Vec<Preload>Preloaded resources (fonts, images).
links: Vec<LinkTag>Extra <link> tags: feeds, preconnect, me, …
html_attributes: Vec<(String, String)>Attributes of the <html> element: (name, value).
theme_colors: Vec<(String, String)>theme-color per media query: (media, color).
Implementations§
Source§impl Metadata
impl Metadata
pub fn new() -> Self
pub fn title(self, v: impl Into<String>) -> Self
pub fn title_template(self, v: impl Into<String>) -> Self
pub fn description(self, v: impl Into<String>) -> Self
pub fn canonical(self, v: impl Into<String>) -> Self
pub fn robots(self, v: impl Into<String>) -> Self
pub fn viewport(self, v: impl Into<String>) -> Self
pub fn theme_color(self, v: impl Into<String>) -> Self
pub fn color_scheme(self, v: impl Into<String>) -> Self
pub fn manifest(self, v: impl Into<String>) -> Self
Sourcepub fn absolute_title(self, v: impl Into<String>) -> Self
pub fn absolute_title(self, v: impl Into<String>) -> Self
A title that ignores ancestor templates.
pub fn keywords<I, S>(self, v: I) -> Self
pub fn icon(self, href: impl Into<String>) -> Self
Sourcepub fn icon_sized(
self,
href: impl Into<String>,
sizes: impl Into<String>,
mime: impl Into<String>,
) -> Self
pub fn icon_sized( self, href: impl Into<String>, sizes: impl Into<String>, mime: impl Into<String>, ) -> Self
An icon with its size and type, for browsers that pick one of several:
icon_sized("/favicon-32x32.png", "32x32", "image/png").
Sourcepub fn theme_color_for(
self,
media: impl Into<String>,
color: impl Into<String>,
) -> Self
pub fn theme_color_for( self, media: impl Into<String>, color: impl Into<String>, ) -> Self
A theme-color for one media query, typically once for each color
scheme: theme_color_for("(prefers-color-scheme: dark)", "#0d1b2a").
A plain theme_color is still written first, for
browsers that ignore media. A child that sets any replaces the
parent’s list.
pub fn apple_touch_icon(self, href: impl Into<String>) -> Self
pub fn open_graph(self, og: OpenGraph) -> Self
pub fn twitter(self, tw: Twitter) -> Self
pub fn alternate(self, lang: impl Into<String>, href: impl Into<String>) -> Self
pub fn meta(self, name: impl Into<String>, content: impl Into<String>) -> Self
pub fn stylesheet(self, href: impl Into<String>) -> Self
Sourcepub fn preload_font(self, href: impl Into<String>) -> Self
pub fn preload_font(self, href: impl Into<String>) -> Self
Preload a font file (adds crossorigin, required for fonts).
pub fn preload_image(self, href: impl Into<String>) -> Self
Sourcepub fn link(self, rel: impl Into<String>, href: impl Into<String>) -> Self
pub fn link(self, rel: impl Into<String>, href: impl Into<String>) -> Self
A <link> tag: link("preconnect", "https://cdn.example.com").
Sourcepub fn html_attribute(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn html_attribute( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
An attribute of the <html> element, e.g. html_attribute("data-theme", "ocean")
or html_attribute("class", "dark"), so a theme applies before any
script runs. lang overrides [app] lang for the page.
The element is written with the document: client-side navigations keep
the attributes the page already has (and what scripts changed since).
Names that are not valid attribute names and event handlers (on*) are
never rendered; values are escaped, and class gets the same short
names as every other class in release builds.
Sourcepub fn feed(
self,
title: impl Into<String>,
href: impl Into<String>,
mime: impl Into<String>,
) -> Self
pub fn feed( self, title: impl Into<String>, href: impl Into<String>, mime: impl Into<String>, ) -> Self
A feed readers can subscribe to. Browsers and feed readers look for
rel="alternate" with a feed media type:
feed("RSS", "/feed.xml", "application/rss+xml").
Sourcepub fn render_head(&self) -> String
pub fn render_head(&self) -> String
Render <head> contents.