summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ennu-html.el57
1 files changed, 57 insertions, 0 deletions
diff --git a/ennu-html.el b/ennu-html.el
index 9a24f9c..877e561 100644
--- a/ennu-html.el
+++ b/ennu-html.el
@@ -8,6 +8,8 @@
(expand-file-name name (concat "/" default-directory)))
(org-export-define-derived-backend 'ennu-html 'html
+ :translate-alist
+ '((inner-template . ennu-html-inner-template))
:options-alist
'((:html-inline-image-rules
nil nil '(("image" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")) t)
@@ -15,6 +17,61 @@
(:thumbnail "THUMBNAIL" nil nil t)
(:translation-group "TRANSLATION_GROUP" nil nil t)))
+(defun ennu-html-inner-template (contents info)
+ (concat
+ ;; Table of contents
+ (let ((depth (plist-get info :with-toc)))
+ (when depth (org-html-toc depth info)))
+ ;; Beginning of h-entry
+ "<article class=\"h-entry\">"
+ ;; Title
+ (format "<h1 class=\"p-name\">%s</h1>\n"
+ (org-export-data (plist-get info :title) info))
+ ;; Author and date
+ (let ((author (when (plist-get info :with-author)
+ (plist-get info :author)))
+ (date (when (plist-get info :with-date)
+ (org-export-get-date info))))
+ (when (or author date)
+ (xmlgen `(p "Published"
+ ,@(when author
+ `(" by "
+ (a :class "p-author h-card"
+ :href ,(ennu--absolute-uri "")
+ ,(car (plist-get info :author)))))
+ ,@(when date
+ `(" on "
+ (time :class "dt-published"
+ :datetime ,(org-export-get-date info "%Y-%m-%d 12:00:00")
+ ,(org-export-get-date info "%B %d, %Y"))))))))
+ ;; Interlanguage language links
+ (format "<p>In other languages: %s</p>"
+ (mapconcat
+ (lambda (translation)
+ (let ((lang (ennu-post-language translation))
+ (slug (ennu-post-slug translation)))
+ (replace-regexp-in-string
+ "<a " (format "<a hreflang=\"%s\" " lang)
+ (ennu-export-post slug lang (plist-get info :backend)))))
+ (plist-get info :translations)
+ ", "))
+ ;; Tags
+ (format "<p>Tags: %s</p>"
+ (mapconcat
+ (lambda (tag)
+ (replace-regexp-in-string
+ "<a " "<a class=\"p-category\" "
+ (ennu-export-tag tag nil (plist-get info :backend))))
+ (plist-get info :filetags) ", "))
+ ;; Summary
+ (format "<div class=\"p-summary\">%s</div>"
+ (org-export-data (plist-get info :summary) info))
+ ;; Document contents
+ (format "<div class=\"e-content\">%s</div>" contents)
+ ;; Footnotes section
+ (org-html-footnote-section info)
+ "</article>"))
+
;; TODO: Pass title through org-export-data-with-backend or something
;; similar in order to export org syntax in title
(defun ennu-export-post (path desc backend)