Open offbyone opened 1 year ago
I feel it depends on the syntax of wiki link that Obsidian uses. According to this part of its documentation, these two are equivalent:
- Wikilink: [[Three laws of motion]]
- Markdown: [Three laws of motion](Three%20laws%20of%20motion.md)
This is different to Markdown-mode and Md-roam.
Md-roam supports [[Title with space]]
or [[id]]
.
So... I think, if you do not wish to override code, your options would be the following:
Have a file name the same as title including the spaces: Title: Three laws of motion File name: Three modes of motion.md
Have the ID the same as the file name including the spaces: ID: Threee laws of motion File name: Three modes of motion.md
Thinking this way, I guess ${title}.md
is a reasonable option.
My roam-fu is a bit weak; are there any negative consequences to dropping the ID slug from the filename?
What does “roam-fu” mean?
Org-roam and Md-roam don’t use file names for backlinks and other functions, if that’s what you are concerned with.
What does “roam-fu” mean?
@smallstepman Thank you. Now I know what it means
using doom:
(use-package! org-roam
:after org
:config
(setq org-roam-directory "/path/to/valut")
(setq org-roam-dailies-directory "Journal/")
)
(use-package! md-roam
:after org-roam
:config
(set-company-backend! 'markdown-mode 'company-capf) ; add company-capf as company backend in markdown buffers
(setq org-roam-file-extensions '("org" "md")) ; enable Org-roam for a markdown files
(md-roam-mode 1) ; md-roam-mode needs to be active before org-roam-db-sync
(org-roam-db-autosync-mode 1)
(map! :map doom-leader-map
"n r o" (λ! (let* ((full-path (buffer-file-name))
(pattern "/MY\\.VAULT/\\(.*?\\)\\.md$")
(vault-name "MY.VAULT")
obsidian-uri match)
(when (and full-path (string-match pattern full-path))
(setq match (match-string 1 full-path))
(setq obsidian-uri (format "obsidian://open?vault=%s&file=%s" vault-name match))
(start-process "open-obsidian" nil "open" obsidian-uri)))))
)
SPC n r o
will open currently open file in your vault, you need to adjust the name of your valut (obsidian://
url must be registered at OS level, on macOS this happens automatically during installation of obsidian (at least when using brew), for linux search for XDG-OPEN-...somethingsometing)
since obsidian doesnt store id of the files in frontmatter by default, you will also have to add some plugins to obsidian to generate unique ID for all files in your valut, I had success with combinations of these two:
Add an ID to all notes
inside obsidian once installed)once you do this, all your obsidian files will be available via org-roam-node-find
I did try to also integrate https://github.com/licht1stein/obsidian.el but it was too slow for me (see issue number 39)
@smallstepman thanks for providing your Doom Emacs code, that really helped!
I'm using the templater plugin with the following code, to pass unique IDs to the markdown frontmatter.
<%*
const date = tp.date.now("YYYYMMDDHHmmss")
title = await tp.system.prompt("Title");
const tags = await tp.system.prompt("Tags");
file_name = date + "-" + title
file_name_slug = file_name.replace(/\s+/g, "_").toLowerCase() // Replace spaces with underscores and convert to lowercase
await tp.file.rename(file_name_slug)
const title_with_spaces = title.replace(/-/g, " ") // Replace hyphens with spaces
_%>
<% "---" %>
title: <% title_with_spaces %>
id: <% date %>
tags: <% tags %>
<% "---" %>
# <%* tR += `${title_with_spaces}` %>
<% tp.file.cursor() %>
As it sits right now, it looks like md-roam does a good job of finding articles by title when using the
[[wiki-style-links]]
but if you open the same file in Obsidian, it tries to create a new top level file without the org-roam ID prefix.As an example, I have a top level node with ID=
20230318085827
and title "PyCascades". My roam template does this:So, the file name for this node would be
20230318085827-pycascades.md
.Obsidian, though, expects the node ID not to be in the filename. Is this something I should drop? Is it worth adding a section in the docs for compatibility with solutions like Obsidian? I suspect that what I need to do is to change my file name to
${title}.md
alone; is that reasonable?