enhance: display block content if it doesn't have a title

e.g. blockquotes, src, etc
This commit is contained in:
Tienson Qin
2021-01-12 21:46:02 +08:00
parent 2ed50ff3c7
commit 163e30e004
2 changed files with 12 additions and 11 deletions

View File

@@ -400,6 +400,7 @@
(util/format "{{{%s %s}}}" name (string/join ", " arguments))
(util/format "{{{%s}}}" name)))
(declare block-content)
(defn block-reference
[config id]
(rum/with-context [[t] i18n/*tongue-context*]
@@ -420,11 +421,14 @@
(route-handler/redirect! {:to :page
:path-params {:name id}})))}
(let [title (:block/title block)
title-blank? (empty? title)]
(->elem
(keyword (str "span.block-ref" (if title-blank? ".is-empty")))
(if title-blank? (t :untitled-block-ref) (map-inline config title))))]]
(let [title (:block/title block)]
(if (empty? title)
;; display the content
[:div.block-ref
(block-content config block nil (:block/uuid block) (:slide? config))]
(->elem
:span.block-ref
(map-inline config title))))]]
[:span.warning.mr-1 {:title "Block ref invalid"}
(util/format "((%s))" id)])))))