1 ;; Inspiration: https://gitlab.com/ambrevar/ambrevar.gitlab.io.
3 ;; TODO: use git time-stamps
7 (add-to-list 'load-path
".")
9 (defun aminb--readfile (filepath)
10 "Return filepath's content."
12 (insert-file-contents filepath
)
15 (defun aminb--find-replace (match-with replace-with string
)
16 "Return the string resulting from replacing `match-with' with
17 `replace-with' in `string'."
18 (when (string-match match-with string
)
19 (replace-match replace-with nil nil string
)))
21 (defun aminb--my-html-body-light-filter (output backend info
)
22 "Make adjustments needed for dark/light mode <input> tag to work."
23 (when (eq backend
'html
)
29 "<body>\n<input class=\"light-off\" id=\"light-off\" type=\"checkbox\">\n<div class=\"page\">"
32 (add-to-list 'org-export-filter-final-output-functions
33 'aminb--my-html-body-light-filter
)
35 ;; re-defining this (originally in `ox-html.el') to add `?g'
36 (defun org-html-format-spec (info)
37 "Return format specification for preamble and postamble.
38 INFO is a plist used as a communication channel."
39 (let ((timestamp-format (plist-get info
:html-metadata-timestamp-format
))
40 (git-repo "<a href=\"https://git.sr.ht/~aminb/aminb.org/commit/?id=%s\">@%s</a>")
41 (git-rev (shell-command-to-string "git rev-parse HEAD"))
42 (git-rev-short (shell-command-to-string "git rev-parse --short HEAD")))
43 `((?t .
,(org-export-data (plist-get info
:title
) info
))
44 (?s .
,(org-export-data (plist-get info
:subtitle
) info
))
45 (?d .
,(org-export-data (org-export-get-date info timestamp-format
)
47 (?T .
,(format-time-string timestamp-format
))
48 (?a .
,(org-export-data (plist-get info
:author
) info
))
50 (lambda (e) (format "<a href=\"mailto:%s\">%s</a>" e e
))
51 (split-string (plist-get info
:email
) ",+ *")
53 (?g .
,(format git-repo git-rev git-rev-short
))
54 (?c .
,(plist-get info
:creator
))
55 (?C .
,(let ((file (plist-get info
:input-file
)))
56 (format-time-string timestamp-format
57 (and file
(nth 5 (file-attributes file
))))))
58 (?v .
,(or (plist-get info
:html-validation-link
) "")))))
60 ;; timestamps can be used to avoid rebuilding everything
61 ;; should probably be put inside the public/ directory
62 (setq org-publish-use-timestamps-flag t
63 org-publish-timestamp-directory
"./")
65 ;; get rid of index.html~ and other backup files that may be created during generation
66 (setq make-backup-files nil
)
68 (setq org-export-with-section-numbers nil
69 org-export-with-smart-quotes t
70 org-export-with-email t
71 org-export-with-date t
72 org-export-with-tags
'not-in-toc
73 org-export-with-toc t
)
75 (setq org-html-divs
'((preamble "header" "preamble")
76 (content "main" "content")
77 (postamble "footer" "postamble"))
78 ;; TODO: link last update to commit history of file
81 org-html-preamble-format
`(("en" ,(aminb--readfile "partials/preamble.html")))
82 org-html-postamble-format
`(("en" ,(aminb--readfile "partials/postamble.html")))
83 org-html-container-element
"section"
84 org-html-metadata-timestamp-format
"%Y-%m-%d"
85 org-html-checkbox-type
'html
86 org-html-html5-fancy t
88 ;; this removes the dependency on `htmlize',
89 ;; but we also lose syntax highlighting.
90 org-html-htmlize-output-type nil
91 org-html-validation-link nil
92 org-html-doctype
"html5")
94 (setq org-publish-project-alist
97 :base-directory
"./source/"
100 :publishing-function
'(org-html-publish-to-html)
101 :publishing-directory
"./public/"
102 :html-head-include-default-style nil
103 :html-head-include-scripts nil
)
105 :base-directory
"source/"
108 :publishing-directory
"./public"
109 :publishing-function
'org-publish-attachment
111 (list "site" :components
'("site-org"))))
113 (defun aminb/publish
()