From 49cd7ac49aad4d60719979bae494ddf15ea37fa1 Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 9 Jul 2023 01:29:44 +0300 Subject: templates: fix cursor usage in feed template --- kittybox-rs/templates/src/mf2.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kittybox-rs/templates/src/mf2.rs b/kittybox-rs/templates/src/mf2.rs index 7f943d3..33cd84a 100644 --- a/kittybox-rs/templates/src/mf2.rs +++ b/kittybox-rs/templates/src/mf2.rs @@ -324,7 +324,7 @@ markup::define! { .iter() .filter_map(|v| v.as_str()) .filter(|v| v != &card["properties"]["uid"][0].as_str().unwrap()) - .filter(|v| !v.starts_with(card["properties"]["author"][0].as_str().unwrap())) + .filter(|v| !card["properties"]["author"][0].as_str().is_some_and(|a| v.starts_with(a))) { li { a."u-url"[href=url, rel="me"] { @url } } } @@ -374,7 +374,11 @@ markup::define! { } } } - @if feed["children"].as_array().map(|a| a.len()).unwrap_or(0) == 0 { + @if let Some(cursor) = cursor { + a[rel="prev", href=format!("{}?after={}", feed["properties"]["uid"][0].as_str().unwrap(), cursor)] { + "Older posts" + } + } else { p { "Looks like you reached the end. Wanna jump back to the " a[href=feed["properties"]["uid"][0].as_str().unwrap()] { @@ -382,12 +386,6 @@ markup::define! { } "?" } } - @if feed["children"].as_array().map(|a| a.len()).unwrap_or(0) == super::POSTS_PER_PAGE { - a[rel="prev", href=feed["properties"]["uid"][0].as_str().unwrap().to_string() - + "?after=" + feed["children"][super::POSTS_PER_PAGE - 1]["properties"]["uid"][0].as_str().unwrap()] { - "Older posts" - } - } } } -- cgit 1.4.1