pub struct DocumentMetadata {
pub title: Option<String>,
pub description: Option<String>,
pub keywords: Vec<String>,
pub author: Option<String>,
pub canonical_url: Option<String>,
pub base_href: Option<String>,
pub language: Option<String>,
pub text_direction: Option<TextDirection>,
pub open_graph: BTreeMap<String, String>,
pub twitter_card: BTreeMap<String, String>,
pub meta_tags: BTreeMap<String, String>,
}Expand description
Document-level metadata extracted from <head> and top-level elements.
Contains all metadata typically used by search engines, social media platforms, and browsers for document indexing and presentation.
§Examples
let doc = DocumentMetadata {
title: Some("My Article".to_string()),
description: Some("A great article about Rust".to_string()),
keywords: vec!["rust".to_string(), "programming".to_string()],
..Default::default()
};
assert_eq!(doc.title, Some("My Article".to_string()));Fields§
§title: Option<String>Document title from <title> tag
description: Option<String>Document description from <meta name="description"> tag
keywords: Vec<String>Document keywords from <meta name="keywords"> tag, split on commas
Document author from <meta name="author"> tag
canonical_url: Option<String>Canonical URL from <link rel="canonical"> tag
base_href: Option<String>Base URL from <base href=""> tag for resolving relative URLs
language: Option<String>Document language from lang attribute
text_direction: Option<TextDirection>Document text direction from dir attribute
open_graph: BTreeMap<String, String>Open Graph metadata (og:* properties) for social media Keys like “title”, “description”, “image”, “url”, etc.
twitter_card: BTreeMap<String, String>Twitter Card metadata (twitter:* properties) Keys like “card”, “site”, “creator”, “title”, “description”, “image”, etc.
Additional meta tags not covered by specific fields Keys are meta name/property attributes, values are content
Trait Implementations§
Source§impl Clone for DocumentMetadata
impl Clone for DocumentMetadata
Source§fn clone(&self) -> DocumentMetadata
fn clone(&self) -> DocumentMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more