diff options
author | Vika <vika@fireburn.ru> | 2024-08-26 17:49:45 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2024-08-26 17:49:45 +0300 |
commit | 14e58b4137f8f77af43cad8b712596c2e1ab7e8a (patch) | |
tree | 841803560949d4fe7e60b232c8dc978c34988ce5 /templates | |
parent | 8f78140825380b808270422c9613999a9399c573 (diff) | |
download | kittybox-14e58b4137f8f77af43cad8b712596c2e1ab7e8a.tar.zst |
Indicate `u-uid` as `rel=canonical`
This only displays on top-level entries, not ones in feeds. This should help search indexers know which URI is the canonical for a given link. I wonder why Google doesn't bother to parse MF2 markup. Do they think themselves monarchs of the Internet, able to show peasants their place? their search results are shitty anyway, I'd rather ask GPT-2. Yes, GPT TWO. Not even 3, 4 or 4o!
Diffstat (limited to 'templates')
-rw-r--r-- | templates/src/mf2.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/templates/src/mf2.rs b/templates/src/mf2.rs index 0b33f9f..4a683d6 100644 --- a/templates/src/mf2.rs +++ b/templates/src/mf2.rs @@ -21,9 +21,9 @@ fn decode_geo_uri(uri: &str) -> String { } markup::define! { - Entry<'a>(post: &'a serde_json::Value) { + Entry<'a>(post: &'a serde_json::Value, from_feed: bool) { @if post.pointer("/properties/like-of").is_none() && post.pointer("/properties/bookmark-of").is_none() { - @FullEntry { post } + @FullEntry { post, from_feed: *from_feed } } else { // Show a mini-post. @MiniEntry { post } @@ -96,7 +96,7 @@ markup::define! { } } } - FullEntry<'a>(post: &'a serde_json::Value) { + FullEntry<'a>(post: &'a serde_json::Value, from_feed: bool) { article."h-entry" { header.metadata { @if let Some(name) = post["properties"]["name"][0].as_str() { @@ -121,7 +121,7 @@ markup::define! { } div { span { - a."u-url"."u-uid"[href=post["properties"]["uid"][0].as_str().unwrap()] { + a."u-url"."u-uid"[href=post["properties"]["uid"][0].as_str().unwrap(), rel=(!from_feed).then_some("canonical")] { @if let Some(published) = post["properties"]["published"][0].as_str() { time."dt-published"[datetime=published] { @chrono::DateTime::parse_from_rfc3339(published) @@ -367,7 +367,7 @@ markup::define! { @if feed["children"].is_array() { @for child in feed["children"].as_array().unwrap() { @match child["type"][0].as_str().unwrap() { - "h-entry" => { @Entry { post: child } } + "h-entry" => { @Entry { post: child, from_feed: true, } } "h-feed" => { @Feed { feed: child, cursor: None } } "h-food" => { @Food { food: child } } //"h-event" => { } |