如何在 ox-publish 生成的 sitemap 文件中插入 HTML 内容?

如题,我知道 ox-publish 可以生成 sitemap,如下设置:

:sitemap-title "Recent changes"
:sitemap-sort-files anti-chronologically
:sitemap-format-entry commonplace/sitemap-format-entry 
:sitemap-filename "recentchanges.org"

这个 recentchanges.org 文件中有所有 publish 出来的 html 静态文件的链接,按照创建时间从新到旧的罗列。

我有个需要就是希望在该文件显示的页面上部显示一个搜索栏,这样我就可以搜索我自己的文章标题了。 就如下图所示:

这个图片显示的页面是自己手动维护的,就是手动链接到其他文章,所以很容易添加这个搜索栏的 HTML 内容。

但是 ox-publish 是用配置命令生成的,我不知道哪里可以 hack?

谁有过相关经验,指导一下,谢谢😊。

我也想知道, 这几天一直在找, 有那位提供下思路也好 这个里面有提到 Org Mode 生成静态站点 Site 【修复版】 - Org-mode - Emacs China https://emacs-china.org/t/org-mode-site/13874/6 这是作者对此的说明 Org To Site Tutor https://www.rosesor.com/org-to-site-tutor.html image 但还不会, 正找学习中

我自己找到了解决方法。 第一步,定义一个函数hurricane/org-publish-sitemap

(defun hurricane/org-publish-sitemap (title list)
  "Customized site map, as a string.
TITLE is the title of the site map.  LIST is an internal
representation for the files to include, as returned by
`org-list-to-lisp'.  PROJECT is the current project."
  (concat "#+SETUPFILE: ../theme-rose.setup\n#+TITLE: " title "\n\n" "
#+HTML: <div class='container-fluid'>
#+HTML:    <div class='row'>
#+HTML:      <div class='col-xs-12 col-md-3'>
#+HTML:        <div id='filter' class='input-group'>
#+HTML:          <input type='text' id='filter-query' placeholder='Search file name or content.' class='form-control input-sm'>
#+HTML:          <a id='filter-clear-query' title='Clear current search...' class='input-group-addon input-sm'>
#+HTML:            <i class='glyphicon glyphicon-remove'>&#x274c;</i>
#+HTML:          </a>
#+HTML:        </div>
#+HTML:      </div>
#+HTML:    </div>
#+HTML: </div>
#+HTML: <ul class='unstyled' id='filter-results'></ul>
" "\n\n"
	        (org-list-to-org list)))

第二步,在org-publish-project-alist 这个中设置:sitemap-functionhurricane/org-publish-sitemap,如下所示:

(setq org-publish-project-alist
            `(("orgfiles"
               .
               .
               .
               :auto-sitemap t
               :exclude "node_modules"
               :sitemap-title "Hurricane"
               :sitemap-sort-files anti-chronologically
               :sitemap-function hurricane/org-publish-sitemap
               :sitemap-format-entry sitemap-format-entry
               :sitemap-filename "index.org"
               )
               .
               .
               .
              
               )
              ("website" :components ("orgfiles" "images"))
              ("statics" :components ("images"))
              ))

多谢! 我用的是 w3.js 来做的, 下午就试好了, 达到要求了, 就是 双引号转义, 搞了半天, 我记得好像 xahlee 有个函数, 可用别的符号来替换, 直接输入 双引号就可以了, 就是找不到了! 现在还有点不顺的就是, org 更改后, 发布更新不及时, 看到网上说, 做的 MD5 的来判断, 相关链接有么? 下面的代码高亮我不会: 抱歉!

(defun hurricane/org-publish-sitemap (title list)
  "Customized site map, as a string.
TITLE is the title of the site map.  LIST is an internal
representation for the files to include, as returned by
`org-list-to-lisp'.  PROJECT is the current project."
  (concat "#+SETUPFILE: ../theme-w3.setup\n#+TITLE: " title "\n\n" "
#+HTML: <input oninput=\"w3.filterHTML('#filter7', 'li', this.value)\" class='w3-input w3-light-gray'>
#+HTML: <div id='filter7' class='w3-teal'>
\n\n"
(org-list-to-org list)
"#+HTML: </div>"
))