renard / o-blog

Standalone orgmode blog exporter. DEPECATED, NOT MAINTAINED
http://renard.github.com/o-blog-v2
260 stars 58 forks source link

Links to other posts do not work #103

Closed dkogan closed 4 years ago

dkogan commented 10 years ago

Hi. I noticed that links to other posts do not work. You can see this in the "Example of some org syntax" sample page; specifically, the "Creating a blog" link. You can even see this in the demo site: http://renard.github.io/o-blog/tips/2012/01/07_example-of-some-org-syntax.html

As a workaround, I added these two new lisp functions (which are generally useful even without this bug):

(defun ob:link-to-post (post)
  (format "%s/%s" (ob:path-to-root) (ob:post-htmlfile post)))

(defun ob:get-post-by-title (title)
  (let ((posts (ob:get-posts
                (lambda (x)
                  (equal title (ob:post-title x)))
                1)))
    (if posts (car posts) nil)))

Then in the blog I say

[[file:{lisp}(ob:link-to-post (ob:get-post-by-title "Post title")){/lisp}][Post title]]

This is perhaps a bit too verbose, but it works. It'd be great if you could merge those two functions (or something similar) into the o-blog source.

Thanks!

igoumeninja commented 10 years ago

I am using YASnippet to help with the syntax. For example if I want to insert a relative link I have the snippet


# -*- mode: snippet -*-
# name: oblog-link
# key: oblog-link
# --
[[file:{lisp}(format "%s/%s" (ob:path-to-root) "/tags/${1:tag}.html"){/lisp}][${2:Tag name}]${}