mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 02:16:30 +00:00
feat: support Arweave URLs for links and images
Adds ar://<tx> URL support for both links and images. The Arweave gateway used can be configured with the :arweave/gateway config key. It defaults to "https://arweave.net" if not configured.
This commit is contained in:
committed by
Tienson Qin
parent
40b315de6b
commit
46ac685474
@@ -262,6 +262,10 @@
|
||||
(when @src
|
||||
(resizable-image config title @src metadata full_text true))))
|
||||
|
||||
(defn ar-url->http-url
|
||||
[href]
|
||||
(string/replace href #"^ar://" (str (state/get-arweave-gateway) "/")))
|
||||
|
||||
;; TODO: safe encoding asciis
|
||||
;; TODO: image link to another link
|
||||
(defn image-link [config url href label metadata full_text]
|
||||
@@ -280,6 +284,9 @@
|
||||
(util/starts-with? href "http")
|
||||
href
|
||||
|
||||
(util/starts-with? href "ar")
|
||||
(ar-url->http-url href)
|
||||
|
||||
config/publishing?
|
||||
(subs href 1)
|
||||
|
||||
@@ -991,6 +998,16 @@
|
||||
(state/set-state! :pdf/current current)))}
|
||||
(get-label-text label)]
|
||||
|
||||
(= protocol "ar")
|
||||
(->elem
|
||||
:a.external-link
|
||||
(cond->
|
||||
{:href (ar-url->http-url href)
|
||||
:target "_blank"}
|
||||
title
|
||||
(assoc :title title))
|
||||
(map-inline config label))
|
||||
|
||||
:else
|
||||
(->elem
|
||||
:a.external-link
|
||||
|
||||
Reference in New Issue
Block a user