ardumont / org2jekyll

Blogging with org-mode and jekyll without alien yaml headers.
GNU General Public License v2.0
71 stars 19 forks source link

Resolve org-roam links #83

Open sati-bodhi opened 1 year ago

sati-bodhi commented 1 year ago

Hello,

Can you please provide the following information?

Thanks in advance.

bug?

This is not exactly a bug, more like a feature request.

M-x org2jekyll-bug-report

System information:
- system-type: gnu/linux
- locale-coding-system: utf-8-unix
- emacs-version: GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
 of 2022-12-09
- org version: 9.6
- org2jekyll version: 0.2.7
- org2jekyll path: /home/sati/.emacs.d/.local/straight/build-28.2/org2jekyll/org2jekyll.el

Expected behavior

I would like to publish some of my org-roam nodes with org2jekyll, but it seems that the internal links that take the form [[id:some-alphanumeric-id][/description/]] do not work out of the box.

Actual behavior

Setting org-publish :publishing-function to org-html-publish-to-html, the above link resolves to <a href="filename.html#ID-some-alphanumeric-id">, which doesn't work.

What works is: <a href="../filename">.

Steps to reproduce the behavior

Publish a node in org-roam with org2jekyll-publish.

How can we try and reproduce?

Please your org2jekyll configuration. And the Compile-Log buffer when it's some suspected packaging problem...

Improvments?

The publishing of org-roam nodes should be supported.

What do you want?

A function like org2jekyll-local-link-export that resolves org-roam links properly.

Why is it better?

Zettels can be published in a blog!

Thanks for sharing!

Cheers,

sati-bodhi commented 1 year ago

I came up with this:

;; Publish org-roam nodes with Jekyll.
;; Function to resolve org-roam links.

(defun org2jekyll-roam-link-export (link description format)
  "Export a man page link from Org files."
  (let ((desc (or description link))
        (file (file-name-base (car (org-roam-id-find link)))))

    (if (string= format "html")
        (format "<a href=\"../%s\">%s</a>" file desc)
      (org2jekyll-message "Unknown format %s, only dealing with html" format))))

(org-link-set-parameters "id"
                         :follow #'org-roam-id-open
                         :export #'org2jekyll-roam-link-export)

Tested this out on my system and it works flawlessly.