add proprety in meta tags

This commit is contained in:
Sara Vieira 2022-12-19 14:04:06 +00:00
parent acb80eeb0b
commit 9d8c50f4d5
2 changed files with 40 additions and 0 deletions

View File

@ -78,6 +78,7 @@ declare_elements! {
content: String,
http_equiv: HTTPEquiv,
name: Metadata,
property: MetadataProperties,
} in [MetadataContent];
style {
type: Mime,
@ -459,3 +460,16 @@ fn test_data_attributes() {
assert_eq!("<div data-id=\"1234\">Boo!</div>", frag.to_string());
}
#[test]
fn test_meta_tags() {
use crate as axohtml;
use crate::{dom::DOMTree, html};
let frag: DOMTree<String> = html!(<meta property="og:url" content="http://example.com"/>
);
assert_eq!(
"<meta content=\"http://example.com\" property=\"og:url\"/>",
frag.to_string()
);
}

View File

@ -254,6 +254,32 @@ pub enum Metadata {
Viewport,
}
#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)]
pub enum MetadataProperties {
#[strum(to_string = "og:title")]
Title,
#[strum(to_string = "og:type")]
Type,
#[strum(to_string = "og:image")]
Image,
#[strum(to_string = "og:url")]
Homepage,
#[strum(to_string = "og:audio")]
Audio,
#[strum(to_string = "og:description")]
Description,
#[strum(to_string = "og:determiner")]
Determiner,
#[strum(to_string = "og:locale")]
Locale,
#[strum(to_string = "og:site_name")]
ParentSiteName,
#[strum(to_string = "og:video")]
Video,
#[strum(to_string = "og:locale:alternate")]
ExtraLocales,
}
#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)]
pub enum OnOff {
#[strum(to_string = "on")]