1. Blog with org mode

I followed the settings on this site to set up my blog with org mode and Jekyll: https://thackl.github.io/blogging-with-emacs-org-mode-and-jekyll

1.1. add pages

  • [X] Good blogs

1.2. add tags

1.3. add static assets

1.4. only publish org files with tag blog

1.4.1. NEXT parse org file

https://emacs.stackexchange.com/questions/35042/parsing-an-orgmode-file-with-org-element-parse-buffer https://orgmode.org/worg/dev/org-element-api.html#parsing

(setq org-ast (with-temp-buffer
                (insert-file-contents "~/Dev/orgs/2022-01-04-203224-aws_solutions_architect_associate_exam.org")
                (org-mode)
                (org-element-parse-buffer)))





(org-element-map org-ast 'keyword
  (lambda (keyword)
    (let ((key (org-element-property :key keyword)))
      (if (string= key "FILETAGS")
          (if (string-match-p (regexp-quote "blog") (org-element-property :value keyword))
              (message (org-element-property :value keyword)))
        ))))

(org-element-map (with-temp-buffer
                   (insert-file-contents "~/Dev/orgs/2022-01-04-203224-aws_solutions_architect_associate_exam.org")
                   (org-mode)
                   (org-element-parse-buffer))
    'keyword
  (lambda (keyword)
    (let ((key (org-element-property :key keyword))
          (val (org-element-property :value keyword)))
      (if (string= key "FILETAGS")
          (if (not (string-match-p (regexp-quote "blog") val))
              (message val))))))



(not (org-element-map (with-temp-buffer
                   (insert-file-contents "~/Dev/orgs/20220101155956-blog_with_org_mode.org")
                   ;; (insert-file-contents "~/Dev/orgs/2022-01-04-203224-aws_solutions_architect_associate_exam.org")
                   (org-mode)
                   (org-element-parse-buffer))
    'keyword
  (lambda (keyword)
    (let ((key (org-element-property :key keyword))
          (val (org-element-property :value keyword)))
      (if (string= key "FILETAGS")
          (string-match-p (regexp-quote "blog") val))))
  nil
  t))

1.5. TODO properly set image links in exported files

reference: https://www.mfoot.com/blog/2015/11/17/using-org-mode-to-write-jekyll-blogs/

(defun org-custom-link-img-follow (path)
  (org-open-file-with-emacs
   (format "../images/%s" path)))

(defun org-custom-link-img-export (path desc format)
  (cond
   ((eq format 'html)
    (format "<img src=\"/assets/%s\" alt=\"%s\"/>" path desc))))

(org-link-set-parameters "img" 'org-custom-link-img-follow 'org-custom-link-img-export)

This works as it sets the custom export function for file type It's sort of a hack because it treats file as image while it could be something else but I don't care at the moment.

(defun org-custom-link-img-export (path desc format)
  (cond
   ((eq format 'html)
    (format "<img src=\"/assets/%s\" alt=\"%s\"/>" path desc))))
(org-link-set-parameters "file" :export 'org-custom-link-img-export)
(org-link-get-parameter "file" :complete)
(org-link-get-parameter "file" :export)
(org-link-get-parameter "file" :follow)

2. TODO Improve code block experience