I'm trying to implement an org-link :export function for the "yeetube"
package that:

1. Starts with a [[yt-video:ID][Link Title]] link.
2. Exports an "https://youtube.com/..."; link in a backend-appropriate
format.

I looked at how, e.g., ol-man does this for inspiration and it
specializes per-backend. I'd like to avoid that if possible.

What I'd _like_ to do is to:

1. Transform my "yt-video" link into an "https" link.
2. Let the current backend decide how it wants to handle the
transformed link.

Currently I have:

    (defun org-export-link-delegate (backend info link &optional desc)
      (org-export-with-backend
       backend
       (car (org-element-parse-secondary-string
             (org-link-make-string link desc) '(link)))
       desc info))

Which I use as follows:

    (defun yeetube--org-export-link (path desc backend info)
      (pcase-let ((rx bos (let type (seq (not ":"))) ":" (let id (+ any)) eos) 
path)
        (pcase scheme
          ("yt-video"
           (org-export-link-delegate backend info (concat yeetube-video-url id) 
desc))
          ("yt-playlist"
           (org-export-link-delegate backend info (concat yeetube-playlist-url 
id) desc))
          ((error "unsupported yeetube link type %s" type)))))

This seems to work, but I'm wondering if there's a better way and/or a
good reason not to do it this way.

Reply via email to