-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there anything like backlinks? #25
Comments
Not in I generate my wiki using
After the export is done, I end up with a bunch of files in At that point, my Another possible approach would be to write an elisp function to go over all the pages in your wiki, search for Override the link exporter;; Override `org-wiki--org-link' to add backlinks support
;; The backlinks themselves will have to be added to the relevant files
;; in a second pass, implemented here with a shell & ed script.
(defun org-wiki--org-link (path desc backend)
"Creates an html org-wiki page link when exporting to HTML,
if and only if the linked page already exists.
Example: the hyperlink [[wiki:Linux][Dealing with Linux]]
will be exported to <a href='Linux.html'>Dealing with Linux</a>
if Linux.org exists, or <span class='missing link'>Dealing with
Linux</span> if it does not."
(cl-case backend
(html
(if (file-exists-p (org-wiki--page->file path))
;; If the destination file exists, then write out the path to
;; the current file to its backlinks file.
(let* ((filename (concat "_cache/"
(replace-regexp-in-string "/" "!" path)
".backlinks"))
(filepath (org-wiki--page->file path))
(folder (file-name-directory filepath)))
(if (file-directory-p folder)
(write-region (concat current-file "\n") nil
filename 'append))
(format "<a href='%s.html'>%s</a>"
path (or desc path)))
;; Otherwise, wrap the `desc' of the link in a <span> with
;; the missing class and add the destination to missing
(progn
(write-region (concat path "\n") nil "_cache/missing" 'append)
(format "<span class='missing link'>%s</span>"
(or desc path)))))))
;; Advice `org-html-publish-to-html' to save the bare name - no
;; path, no extension - of the file it is invoked on, so that
;; `org-wiki--org-link' can know which page is linking to which
;; when outputting backlinks.
(advice-add #'org-html-publish-to-html :before
(lambda (plist filename pub-dir)
(setq current-file (file-name-base filename))))
|
Backlinks known from wikis available in org-wiki?
The text was updated successfully, but these errors were encountered: