Skip to main content

SeoBuilder

Struct SeoBuilder 

Source
pub struct SeoBuilder { /* private fields */ }
Expand description

A fluent builder for a page’s whole metadata block.

Implements WINGED_RUST_SPEC.md §6 on top of the functions above.

§Examples

use winged_rust::prelude::*;
use winged_rust::seo::SeoBuilder;

let tags = SeoBuilder::new("RideKeeper", "Motorcycle maintenance companion")
    .image("https://ridekeeper.example/og.jpg")
    .url("https://ridekeeper.example")
    .twitter_site("@micheltlutz")
    .build();

let rendered: String = tags.iter().map(Render::render).collect();
assert!(rendered.contains(r#"<meta property="og:title" content="RideKeeper">"#));

Implementations§

Source§

impl SeoBuilder

Source

pub fn new( page_title: impl Into<String>, description: impl Into<String>, ) -> Self

Starts a metadata block from the two fields every page needs.

Source

pub fn image(self, image_url: impl Into<String>) -> Self

Sets the preview image used by both Open Graph and Twitter.

Source

pub fn url(self, page_url: impl Into<String>) -> Self

Sets the canonical page URL.

Source

pub fn site_name(self, site_name: impl Into<String>) -> Self

Sets og:site_name.

Source

pub fn author(self, author: impl Into<String>) -> Self

Sets the page author.

Source

pub fn keywords<S: Into<String>>( self, keywords: impl IntoIterator<Item = S>, ) -> Self

Sets the keyword list.

Source

pub fn twitter_card(self, card: impl Into<String>) -> Self

Overrides the Twitter card type.

Source

pub fn twitter_site(self, site: impl Into<String>) -> Self

Sets twitter:site.

Source

pub fn twitter_creator(self, creator: impl Into<String>) -> Self

Sets twitter:creator.

Source

pub fn build(&self) -> Vec<Element>

Builds the tags: the common block, then Open Graph, then Twitter Cards.

That order matches Winged-Swift’s SEO.complete, and the golden fixture depends on it.

Trait Implementations§

Source§

impl Clone for SeoBuilder

Source§

fn clone(&self) -> Self

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 SeoBuilder

Source§

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

Formats the value using the given formatter. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more