#+TITLE: Emacs Org-roam Configuration
#+property: header-args :tangle ~/.emacs.d/modules/roam.el

* org-roam Setup
#+begin_src elisp
  (use-package org-roam
    :init (setq org-roam-v2-ack t)
    :after org
    :config
    (org-roam-db-autosync-enable)
    (require 'org-roam-dailies)
    (setq org-roam-mode-sections
  	(list #'org-roam-backlinks-section
                #'org-roam-reflinks-section
                #'org-roam-unlinked-references-section
                )
  	)
    :bind  (
  	  ("C-c n f" . org-roam-node-find)
  	  ("C-c n g" . org-roam-graph)
  	  ("C-c n r" . org-roam-node-random)
  	  ("C-c n h" . org-roam-node-convert-headline)
  	  ("C-c n i" . org-roam-node-insert)
  	  ("C-c n o" . org-id-get-create)
  	  ("C-c n t" . org-roam-tag-add)
  	  ("C-c n a" . org-roam-alias-add)
  	  ("C-c n l" . org-roam-buffer-display-dedicated)
  	  )
    )
#+end_src

* Directories
#+begin_src elisp
  (setq org-roam-directory (concat org-directory "/1_thinking"))
  (setq org-roam-dailies-directory (concat org-directory "/0_inbox/daily"))
  (setq org-roam-file-exclude-regexp "^[.][.]?/")
#+end_src

* Capture Templates
#+begin_src elisp
  (setq org-roam-capture-templates
        '(
          ("L" "link" plain
           (function org-roam--capture-get-point)
           "%?"
           :file-name "web/%<%Y-%m-%dT%H%M%S>.org"
           :head "#+TITLE: ${title}\n#+CREATED: %<%Y-%m-%dT%H%M%S>"
           :immediate-finish t
           :unnarrowed t
           )
          ("h" "hugo post" plain
           "%?"
           :target (file+head "posts/${slug}.org"
                              "#+TITLE: ${title}\n#+DATE: %U\n#+HUGO_BASE_DIR: ~/gharbeia.net\n#+HUGO_SECTION: ./posts\n#+HUGO_AUTO_SET_LASTMOD: t\n#+HUGO_TAGS: article\n#+HUGO_DRAFT: true\n")
           :immediate-finish t
           :unnarrowed t
           )
          ("p" "person" plain
           "%?"
           :if-new (file+head "people/${slug}.org"
                             "#+TITLE: ${title}")
          :immediate-finish t
          :unnarrowed t
          )
         )
       )

  (setq org-roam-dailies-capture-templates
        '(
          ("d" "daily" plain
           ""
          :target ("file+heaed %<%Y-%m-%d>.org"  "#+title: %<%Y-%m-%d>\n\n")
          :immediate-finish t
          )
         )
       )
#+end_src
