diff --git a/lib/host/blog.sx b/lib/host/blog.sx index 24cae789..419a0588 100644 --- a/lib/host/blog.sx +++ b/lib/host/blog.sx @@ -776,8 +776,31 @@ (fn (node) (if (= (type-of node) "list") (let ((h (str (first node)))) - (cond ((= h "ref") "card") ((= h "alt") "cond") ((= h "each") "each") (else "other"))) + (cond + ((= h "ref") "card") ((= h "alt") "cond") ((= h "each") "each") + ((= h "text") "text") + ((or (= h "row") (= h "grid")) "layout") + ((or (= h "field") (= h "val")) "field") + ((= h "seq") "group") + (else "other"))) "other"))) +;; a short human display of ANY composition node — for the editor rows. A ref becomes a +;; ✎ edit-chip; text/field/val show their content; a container shows its item count. +(define host/blog--node-display + (fn (slug node) + (if (= (type-of node) "list") + (let ((h (str (first node)))) + (cond + ((= h "ref") (host/blog--ref-chip slug (str (first (rest node))))) + ((= h "text") (let ((t (str (first (rest node))))) (if (> (len t) 50) (str (substr t 0 50) "…") t))) + ((or (= h "field") (= h "val")) (str h " " (str (first (rest node))))) + ((or (= h "seq") (= h "row") (= h "grid")) (str h " (" (len (rest node)) ")")) + (else h))) + (str node)))) +;; the display of a conditional/repeater BRANCH — its last element (a ref, text, or group). +(define host/blog--branch-display + (fn (slug branch) + (host/blog--node-display slug (host/blog--nth branch (- (len branch) 1))))) ;; every ref slug a node (transitively) contains — for `contains`-edge cleanup on remove. (define host/blog--node-refs (fn (node) @@ -1587,27 +1610,29 @@ (let ((kind (host/blog--node-kind node)) (rs "display:flex;gap:0.5em;align-items:center;border:1px solid #ddd;padding:0.4em;margin:0.2em 0")) (cond - ((= kind "card") - (quasiquote (li :style (unquote rs) - (b :style "min-width:5em" "card") - (span :style "flex:1" (unquote (host/blog--ref-chip slug (str (first (rest node)))))) - (unquote (host/blog--block-ctrls slug idx))))) + ;; CONDITIONAL: the condition