about summary refs log tree commit diff
path: root/templates/src
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-03-04 02:48:51 +0300
committerVika <vika@fireburn.ru>2024-03-04 02:48:51 +0300
commite7b742f3a9d0fff13257d7d5dd1d843026a8bb1c (patch)
tree2e2b77edf4904030c8ae5f9ef74a418971f24a2f /templates/src
parent01018aae84e9f1f992918b709997d09beb7c411d (diff)
downloadkittybox-e7b742f3a9d0fff13257d7d5dd1d843026a8bb1c.tar.zst
kittybox-templates: fix icons on bookmark posts
Diffstat (limited to 'templates/src')
-rw-r--r--templates/src/mf2.rs43
1 files changed, 16 insertions, 27 deletions
diff --git a/templates/src/mf2.rs b/templates/src/mf2.rs
index 2c41de9..0b33f9f 100644
--- a/templates/src/mf2.rs
+++ b/templates/src/mf2.rs
@@ -46,7 +46,7 @@ markup::define! {
                         @author["properties"]["name"][0].as_str().unwrap()
                     }
                 }
-                @if let Some(likeof) = post["properties"]["like-of"][0].as_str() {
+                @if post["properties"].as_object().unwrap().contains_key("like-of") {
                     " "
                     span."like-icon"["aria-label"="liked"] {
                         span."like-icon-label"["aria-hidden"="true"] {
@@ -54,42 +54,31 @@ markup::define! {
                         }
                     }
                     " "
-                    a."u-like-of"[href=likeof] { @likeof }
-                } else if let Some(likeof) = post["properties"]["like-of"][0].as_object() {
-                    " "
-                    span."like-icon"["aria-label"="liked"] {
-                        span."like-icon-label"["aria-hidden"="true"] {
-                            "❤️"
-                        }
-                    }
-                    " "
-                    a."u-like-of"[href=likeof["properties"]["url"][0].as_str().unwrap()] {
-                        @likeof["properties"]["name"][0]
+                    @if let Some(likeof) = post["properties"]["like-of"][0].as_str() {
+                        a."u-like-of"[href=likeof] { @likeof }
+                    } else if let Some(likeof) = post["properties"]["like-of"][0].as_object() {
+                        a."u-like-of"[href=likeof["properties"]["url"][0].as_str().unwrap()] {
+                            @likeof["properties"]["name"][0]
                             .as_str()
                             .unwrap_or_else(|| likeof["properties"]["url"][0].as_str().unwrap())
-                    }
-                }
-                @if let Some(bookmarkof) = post["properties"]["bookmark-of"][0].as_str() {
-                    " "
-                    span."like-icon"["aria-label"="bookmarked"] {
-                        span."bookmark-icon-label"["aria-hidden"="true"] {
-                            "🔖"
                         }
                     }
+                } else if post["properties"].as_object().unwrap().contains_key("bookmark-of") {
                     " "
-                    a."u-bookmark-of"[href=bookmarkof] { @bookmarkof }
-                } else if let Some(bookmarkof) = post["properties"]["bookmark-of"][0].as_object() {
-                    " "
-                    span."like-icon"["aria-label"="bookmarked"] {
+                    span."bookmark-icon"["aria-label"="bookmarked"] {
                         span."bookmark-icon-label"["aria-hidden"="true"] {
                             "🔖"
                         }
                     }
                     " "
-                    a."u-bookmark-of"[href=bookmarkof["properties"]["url"][0].as_str().unwrap()] {
-                        @bookmarkof["properties"]["name"][0]
-                            .as_str()
-                            .unwrap_or_else(|| bookmarkof["properties"]["url"][0].as_str().unwrap())
+                    @if let Some(bookmarkof) = post["properties"]["bookmark-of"][0].as_str() {
+                        a."u-bookmark-of"[href=bookmarkof] { @bookmarkof }
+                    } else if let Some(bookmarkof) = post["properties"]["bookmark-of"][0].as_object() {
+                        a."u-bookmark-of"[href=bookmarkof["properties"]["url"][0].as_str().unwrap()] {
+                            @bookmarkof["properties"]["name"][0]
+                                .as_str()
+                                .unwrap_or_else(|| bookmarkof["properties"]["url"][0].as_str().unwrap())
+                        }
                     }
                 }
                 " "