feat(org): Configure org project alist
Add configuration to produce blog to org-publish-alist
This commit is contained in:
parent
47facf5c8b
commit
e66629c6bd
111
config.org
111
config.org
@ -556,6 +556,117 @@ $x + 1 = 3$
|
||||
#+end_src
|
||||
#+RESULTS:
|
||||
| inline-anki-link-filter |
|
||||
*** HTML
|
||||
**** Custom functions
|
||||
A lot of this section I steal from [[https://gitlab.com/to1ne/blog/blob/master/elisp/publish.el#L170-204][writepermission.com]].
|
||||
He has some great work for rss feed creation and other stuff.
|
||||
#+begin_src elisp
|
||||
(defun rw/format-rss-feed-entry (entry style project)
|
||||
"Format ENTRY for the RSS feed.
|
||||
ENTRY is a file name. STYLE is either 'list' or 'tree'.
|
||||
PROJECT is the current project."
|
||||
(cond ((not (directory-name-p entry))
|
||||
(let* ((file (org-publish--expand-file-name entry project))
|
||||
(title (org-publish-find-title entry project))
|
||||
(date (format-time-string "%Y-%m-%d" (org-publish-find-date entry project)))
|
||||
(link (concat (file-name-sans-extension entry) ".html")))
|
||||
(with-temp-buffer
|
||||
(org-mode)
|
||||
(insert (format "* [[file:%s][%s]]\n" file title))
|
||||
(org-set-property "RSS_PERMALINK" link)
|
||||
(org-set-property "PUBDATE" date)
|
||||
(insert-file-contents file)
|
||||
(buffer-string))))
|
||||
((eq style 'tree)
|
||||
;; Return only last subdir.
|
||||
(file-name-nondirectory (directory-file-name entry)))
|
||||
(t entry)))
|
||||
|
||||
(defun rw/format-rss-feed (title list)
|
||||
"Generate RSS feed, as a string.
|
||||
TITLE is the title of the RSS feed. LIST is an internal
|
||||
representation for the files to include, as returned by
|
||||
`org-list-to-lisp'. PROJECT is the current project."
|
||||
(concat "#+TITLE: " title "\n\n"
|
||||
(org-list-to-subtree list 1 '(:icount "" :istart ""))))
|
||||
|
||||
(defun rw/org-rss-publish-to-rss (plist filename pub-dir)
|
||||
"Publish RSS with PLIST, only when FILENAME is 'rss.org'.
|
||||
PUB-DIR is when the output will be placed."
|
||||
(if (equal "rss.org" (file-name-nondirectory filename))
|
||||
(let ((file-name (org-rss-publish-to-rss plist filename pub-dir)))
|
||||
(shell-command (format "tail -n +2 %s > random-file-temp.xml" file-name file-name))
|
||||
(shell-command (format "mv random-file-temp.xml %s" file-name))
|
||||
file-name)))
|
||||
|
||||
(use-package! ox-rss)
|
||||
#+end_src
|
||||
|
||||
We will need ox-rss for rss feed production.
|
||||
#+begin_src elisp :tangle packages.el
|
||||
(package! ox-rss)
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
**** Project list configuration
|
||||
Finally, configure the project alist using a series of projects.
|
||||
1. ~blog-posts~ processes the normal .org file to create posts.
|
||||
2. ~blog-static~ brings static css and images into the publishing dir.
|
||||
3. ~blog-rss~ creates the rss feed as a special type of sitemap. It uses ox-rss, which we just loaded!
|
||||
4. Finally, the whole blog. This uses both blog-posts and blog-rss.
|
||||
#+begin_src elisp :results none
|
||||
(setq org-html-htmlize-output-type 'css
|
||||
org-html-html5-fancy t
|
||||
org-html-metadata-timestamp-format "%Y-%m-%d"
|
||||
org-html-checkbox-type 'html
|
||||
org-html-doctype "html5")
|
||||
(let ((blog--root (concat (file-name-as-directory org-directory) "blog"))
|
||||
(blog--public-root "~/10-19-personal-projects/15-blog")
|
||||
(blog--url "https://judah.freedomland.xyz")
|
||||
(blog--static-attachment-extensions (regexp-opt '("jpg" "jpeg" "gif" "png" "svg" "pdf" "css"))))
|
||||
(setq org-publish-project-alist
|
||||
(list
|
||||
(list "blog-posts"
|
||||
:auto-sitemap t
|
||||
:base-directory blog--root
|
||||
:exclude (regexp-opt '("rss.org"))
|
||||
:html-htmlized-css-url "static/style.css"
|
||||
:html-head-include-default-style nil
|
||||
:publishing-directory blog--public-root
|
||||
:publishing-function 'org-html-publish-to-html
|
||||
:recursive nil
|
||||
:sitemap-filename "index.org"
|
||||
:sitemap-title "Judah Sotomayor's Blog"
|
||||
:sitemap-sort-files 'anti-chronologically
|
||||
:sitemap-style 'tree)
|
||||
(list "blog-static"
|
||||
:base-directory (expand-file-name "static" blog--root)
|
||||
:base-extension blog--static-attachment-extensions
|
||||
:publishing-directory (expand-file-name "static" blog--public-root)
|
||||
:publishing-function 'org-publish-attachment
|
||||
:recursive t)
|
||||
(list "blog-rss"
|
||||
:auto-sitemap t
|
||||
:base-directory blog--root
|
||||
:exclude (regexp-opt '("rss.org" "index.org" "404.org"))
|
||||
:html-link-home blog--url
|
||||
:html-link-use-abs-url t
|
||||
:html-link-org-files-as-html t
|
||||
:publishing-directory blog--public-root
|
||||
:publishing-function 'rw/org-rss-publish-to-rss
|
||||
:rss-extension "xml"
|
||||
:sitemap-filename "rss.org"
|
||||
:sitemap-format-entry 'rw/format-rss-feed-entry
|
||||
:sitemap-function 'rw/format-rss-feed
|
||||
:sitemap-sort-files 'anti-chronologically
|
||||
:sitemap-style 'list)
|
||||
(list "blog"
|
||||
:components '("blog-posts" "blog-rss" "blog-static")))))
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
|
||||
** Automatic Citations with *citar* and *org-cite*
|
||||
:PROPERTIES:
|
||||
|
Loading…
Reference in New Issue
Block a user