Add hacky workaround for Mastodon link verification

This commit is contained in:
Zoey 2022-11-08 10:36:31 -08:00
parent 533ec7e7a3
commit 1bc57f675b
No known key found for this signature in database
GPG key ID: 0E87B6A5795E040B

View file

@ -155,9 +155,14 @@ impl<'a> SiteBuilder<'a> {
}),
element!("a", |el| {
if let Some(href) = el.get_attribute("href") {
let me = href == "https://mas.to/@zyl";
if let Ok(href) = Url::parse(&href) {
if href.host().is_some() {
el.set_attribute("rel", "noopener noreferrer")?;
let mut rel = String::from("noopener noreferrer");
if me {
rel.push_str(" me");
}
el.set_attribute("rel", &rel)?;
el.set_attribute("target", "_blank")?;
}
}