From 9f26203ed51bec7c506c06d5e2c0d5c2ee91a1ad Mon Sep 17 00:00:00 2001 From: Bendik Aagaard Lynghaug Date: Tue, 25 Aug 2026 20:04:35 +0200 Subject: [PATCH] Resource empty text: content-declared, and null counts as empty A `.[] | {...}` jq over an empty list yields no output, which arrived as null and rendered nothing - redoal's Releases feature was a bare heading. Null now reads as the same silence as [], and ResourceSpec gains `empty:` so content can word it ("Nothing released yet"); default stays "Nothing here yet." Co-Authored-By: Claude Fable 5 --- src/app.rs | 12 +++++++++++- src/content.rs | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index bd08c6f..a42758c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -900,6 +900,7 @@ fn AlternativeCard( alternative=alt_name.clone() feature_name=feature_name.clone() transitions=spec.transitions.clone() + empty=spec.empty.clone() pending_transitions=pending_transitions transition_batch=transition_batch /> @@ -1219,6 +1220,7 @@ fn ResourceFeature( alternative: String, feature_name: String, transitions: Vec, + empty: Option, pending_transitions: RwSignal>, transition_batch: ServerAction, ) -> impl IntoView { @@ -1252,6 +1254,7 @@ fn ResourceFeature( {move || { let feature_name = feature_name.clone(); let transitions = transitions.clone(); + let empty = empty.clone().unwrap_or_else(|| "Nothing here yet.".to_string()); data.get() .map(|res| match res { Ok(value) => { @@ -1259,6 +1262,7 @@ fn ResourceFeature( , + empty: String, value: serde_json::Value, pending_transitions: RwSignal>, transition_batch: ServerAction, ) -> impl IntoView { + // A jq like `.[] | {...}` over an empty list yields no output at + // all - that arrives as null, and it's the same silence as []. + if value.is_null() { + return view! {

{empty}

}.into_any(); + } if let serde_json::Value::Array(items) = &value { if let Ok(answers) = serde_json::from_value::>(value.clone()) { let mut answers = answers; @@ -1323,7 +1333,7 @@ fn ResourceValue( .into_any(); } if items.is_empty() { - return view! {

"Nothing here yet."

}.into_any(); + return view! {

{empty}

}.into_any(); } // A list of plain objects (e.g. a jq-shaped GiteaStarred/Url // resource) - render as cards rather than dumping raw JSON. diff --git a/src/content.rs b/src/content.rs index b0c6b78..10fe99f 100644 --- a/src/content.rs +++ b/src/content.rs @@ -202,6 +202,12 @@ pub struct ResourceSpec { /// `.[] | {name, url: .html_url}`. `None` returns it as-is. #[serde(default)] pub jq: Option, + /// What to say when the resource yields nothing - an empty list, + /// or `null` (a `.[] | ...` jq over an empty list produces no + /// output at all). Defaults to "Nothing here yet."; content sets + /// it where the silence needs a voice ("Nothing released yet"). + #[serde(default)] + pub empty: Option, } /// Where a resource's live data comes from. `Kv` (a NATS KV bucket