Browse Source

fix: image link

Tienson Qin 4 months ago
parent
commit
0e953e2572
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/main/frontend/components/block.cljs

+ 8 - 1
src/main/frontend/components/block.cljs

@@ -308,6 +308,10 @@
   [asset-block src title metadata {:keys [breadcrumb? positioned? local? full-text]}]
   (let [*el-ref (rum/use-ref nil)
         image-src (fs/asset-path-normalize src)
+        src' (if (or (string/starts-with? src "/")
+                     (string/starts-with? src "~"))
+               (str "file://" src)
+               src)
         get-blockid #(some-> (rum/deref *el-ref) (.closest "[blockid]") (.getAttribute "blockid") (uuid))]
     [:div.asset-container
      {:key "resize-asset-container"
@@ -321,7 +325,7 @@
       (merge
        {:loading "lazy"
         :referrerPolicy "no-referrer"
-        :src src
+        :src src'
         :title title}
        metadata)]
      (when (and (not breadcrumb?)
@@ -600,6 +604,9 @@
                     (util/starts-with? href "http")
                     href
 
+                    (or (util/starts-with? href "/") (util/starts-with? href "~"))
+                    href
+
                     config/publishing?
                     (subs href 1)