garden/content/daily/2024-10-07.md

27 lines
1.3 KiB
Markdown
Raw Normal View History

2024-10-07 17:11:53 +02:00
+++
title = 2024-10-07
author = ["SouthFox"]
date = 2024-10-07T22:46:00+08:00
lastmod = 2024-10-07T23:11:25+08:00
tags = ["publish"]
draft = false
+++
## org-roam 发布过滤指定层级 {#org-roam-发布过滤指定层级}
也是一个 [来把 org-roam 笔记发布出去吧]({{< relref "../articles/来把 org-roam 笔记发布出去吧.md" >}}) 的文章的持续优化,思想是把当前缓冲复制到一个临时缓冲然后将光标放到指定层级然后调用 `org-cut-subtree` 进行删除,然后对于 ox-hugo 这个包发布需要设定 `EXPORT_FILE_NAME` 这个 KEYWORD ,可以是二用 `org-roam-set-keyword` 进行设置,但获取就需要自己写了,通过 `org-collect-keywords` 然后 cad car 的还是有点混乱,不过现在先凑合用着吧,总之最后做到的效果就是把指定层级给删除了。
```emacs-lisp
(let ((publish-content (buffer-string)))
(with-current-buffer (get-buffer-create "*Garden*")
(erase-buffer)
(insert publish-content)
(org-mode)
(org-roam-set-keyword "EXPORT_FILE_NAME" (cadar (org-collect-keywords '("title"))))
(if-let ((headline (org-find-exact-headline-in-buffer "总结")))
(progn
(goto-char headline)
(org-cut-subtree)))
(org-hugo-export-wim-to-md)))
```