#[non_exhaustive]pub struct MetaTagGroups {
pub apple: String,
pub primary: String,
pub og: String,
pub ms: String,
pub twitter: String,
}Expand description
Holds collections of meta tags for different platforms and categories.
Each field is the rendered <meta> elements of one group, one per
line. MetaTagGroups::iter gives the same tags as values.
§Example
use metadata_gen::metatags::generate_metatags;
use metadata_gen::MetadataMap;
let mut metadata = MetadataMap::new();
metadata.insert("description".to_string(), "A sample page".to_string());
metadata.insert("og:title".to_string(), "Sample".to_string());
let tags = generate_metatags(&metadata);
assert!(tags.primary.contains("description"));
assert!(tags.og.contains(r#"property="og:title""#));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.apple: StringMeta tags specific to Apple devices.
primary: StringPrimary meta tags (description, keywords, author, viewport).
og: StringOpen Graph meta tags.
ms: StringMicrosoft-specific meta tags.
twitter: StringTwitter meta tags.
Implementations§
Source§impl MetaTagGroups
impl MetaTagGroups
Sourcepub fn add_custom_tag(&mut self, name: &str, content: &str)
pub fn add_custom_tag(&mut self, name: &str, content: &str)
Adds a custom meta tag to the appropriate group, chosen by its
name: apple-* and mobile-web-app-capable go to apple,
msapplication-* to ms, Open Graph prefixes to og,
twitter:* to twitter, everything else to primary.
§Example
use metadata_gen::MetaTagGroups;
let mut groups = MetaTagGroups::default();
groups.add_custom_tag("og:locale", "en_GB");
assert_eq!(groups.og, r#"<meta property="og:locale" content="en_GB">"#);Sourcepub fn format_meta_tag(&self, name: &str, content: &str) -> String
pub fn format_meta_tag(&self, name: &str, content: &str) -> String
Formats one meta tag as MetaTag::render does.
§Example
use metadata_gen::MetaTagGroups;
let groups = MetaTagGroups::default();
assert_eq!(
groups.format_meta_tag("description", r#"say "hi""#),
r#"<meta name="description" content="say "hi"">"#
);Generates the Apple-specific group from metadata.
Generates the primary group (author, description, keywords,
viewport) from metadata.
Generates the Open Graph group from metadata.
Generates the Microsoft-specific group from metadata.
Generates the Twitter group from metadata.
Renders every tag in tags that has a value in metadata, one
per line, in the order given.
§Example
use metadata_gen::{MetaTagGroups, MetadataMap};
let mut metadata = MetadataMap::new();
metadata.insert("author".into(), "Ada".into());
let groups = MetaTagGroups::default();
assert_eq!(
groups.generate_tags(&metadata, &["author", "missing"]),
r#"<meta name="author" content="Ada">"#
);Sourcepub fn iter(&self) -> impl Iterator<Item = MetaTag> + '_
pub fn iter(&self) -> impl Iterator<Item = MetaTag> + '_
Every rendered element across the five groups, in group order,
as MetaTag values again.
§Example
use metadata_gen::MetaTagGroups;
let mut groups = MetaTagGroups::default();
groups.add_custom_tag("og:title", "T");
groups.add_custom_tag("author", "A");
let names: Vec<String> = groups.iter().map(|t| t.name).collect();
assert_eq!(names, ["author", "og:title"]);Trait Implementations§
Source§impl Clone for MetaTagGroups
impl Clone for MetaTagGroups
Source§impl Debug for MetaTagGroups
impl Debug for MetaTagGroups
Source§impl Default for MetaTagGroups
impl Default for MetaTagGroups
Source§impl Display for MetaTagGroups
impl Display for MetaTagGroups
impl Eq for MetaTagGroups
Source§impl Hash for MetaTagGroups
impl Hash for MetaTagGroups
Source§impl PartialEq for MetaTagGroups
impl PartialEq for MetaTagGroups
impl StructuralPartialEq for MetaTagGroups
Auto Trait Implementations§
impl Freeze for MetaTagGroups
impl RefUnwindSafe for MetaTagGroups
impl Send for MetaTagGroups
impl Sync for MetaTagGroups
impl Unpin for MetaTagGroups
impl UnsafeUnpin for MetaTagGroups
impl UnwindSafe for MetaTagGroups
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.