I occasionally post snippets from my Emacs configuration file, drafting the notes directly in my literate config and posting them via org2blog. I figured it might be a good idea to include a link to my config at the end of the posts, but I didn’t want to scatter redundant links in my config file itself. Wouldn’t it be cool if the link could be automatically added whenever I use org2blog to post a subtree from my config file? I think the code below accomplishes that.
(defun my/org-export-filter-body-add-emacs-configuration-link (string backend info) (concat string "\n<div class=\"note\">This is part of my <a href=\"https://sachachua.com/dotemacs\">Emacs configuration.</a></div>")) (use-package org2blog :config (advice-add 'org2blog-entry-save :around (lambda (orig-fun &rest args) (if (string-match "\\.emacs\\.d/Sacha\\.org" (buffer-file-name)) (let ((org-export-filter-body-functions (cons 'my/org-export-filter-body-add-emacs-configuration-link org-export-filter-body-functions))) (apply orig-fun args)) (apply orig-fun args)))))
This is part of my Emacs configuration.