" (string-trim code))))
;; (defun my/org-html-special-block (special-block contents info)
;; "Transcode a SPECIAL-BLOCK element from Org to HTML.
;; CONTENTS holds the contents of the block. INFO is a plist
;; holding contextual information."
;; (let* ((block-type (org-element-property :type special-block))
;; (attributes (org-export-read-attribute :attr_html special-block)))
;; (format "
\n%s\n
"
;; block-type
;; (or contents
;; (if (string= block-type "cta")
;; "If you find this guide helpful, please consider supporting System Crafters via the links on the How to Help page!"
;; "")))))
(org-export-define-derived-backend 'site-html 'html
:translate-alist
'((template . my/org-html-template)
(link . my/org-html-link)
(src-block . my/org-html-src-block)
;; (special-block . my/org-html-special-block)
(headline . my/org-html-headline))
:options-alist
'((:video "VIDEO" nil nil)))
(defun org-html-publish-to-html (plist filename pub-dir)
"Publish an org file to HTML, using the FILENAME as the output directory."
(let ((article-path (get-article-output-path filename pub-dir)))
(cl-letf (((symbol-function 'org-export-output-file-name)
(lambda (extension &optional subtreep pub-dir)
;; The 404 page is a special case, it must be named "404.html"
(concat article-path
(if (string= (file-name-nondirectory filename) "404.org") "404" "index")
extension))))
(org-publish-org-to 'site-html
filename
(concat "." (or (plist-get plist :html-extension)
"html"))
plist
article-path))))
(defun my/rss-extract-title (html-file)
"Extract the title from an HTML file."
(with-temp-buffer
(insert-file-contents html-file)
(let ((dom (libxml-parse-html-region (point-min) (point-max))))
(dom-text (car (dom-by-class dom "site-post-title"))))))
(defun my/rss-extract-date (html-file)
"Extract the post date from an HTML file."
(with-temp-buffer
(insert-file-contents html-file)
(let* ((dom (libxml-parse-html-region (point-min) (point-max)))
(date-string (dom-text (car (dom-by-class dom "site-post-meta"))))
(parsed-date (parse-time-string date-string))
(day (nth 3 parsed-date))
(month (nth 4 parsed-date))
(year (nth 5 parsed-date)))
;; NOTE: Hardcoding this at 8am for now
(encode-time 0 0 8 day month year))))
(setq webfeeder-title-function #'my/rss-extract-title
webfeeder-date-function #'my/rss-extract-date)
;; (setq org-publish-use-timestamps-flag nil)
;; (setq org-html-validation-link nil
;; org-html-head-include-scripts nil
;; org-html-head-include-default-style nil
;; org-html-preamble nil
;; org-html-postamble nil
;; org-html-use-infojs nil
;; )
(setq org-publish-use-timestamps-flag t
org-publish-timestamp-directory "./.org-cache/"
org-export-with-section-numbers nil
org-export-use-babel nil
org-export-with-smart-quotes t
org-export-with-sub-superscripts nil
org-export-with-tags 'not-in-toc
org-html-htmlize-output-type 'css
org-html-prefer-user-labels t
;; org-html-link-home my/site-url
org-html-link-use-abs-url t
org-html-link-org-files-as-html t
org-html-html5-fancy t
org-html-self-link-headlines t
org-export-with-toc nil
make-backup-files nil)
(setq org-publish-project-alist
(list '("cosmicflow:main"
:base-directory "./content"
:base-extension "org"
:publishing-directory "./public/cosmicflow-html"
:publishing-function org-html-publish-to-html
:with-title nil
;;:with-author nil
;;:with-creator nil
;;:email nil
:with-timestamps nil)
'("cosmicflow:assets"
:base-directory "./assets"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|woff2\\|ttf"
:publishing-directory "./public/cosmicflow-html"
:recursive t
:publishing-function org-publish-attachment)
'("cosmicpirates-gmi"
:base-directory "./content"
:base-extension "org"
:publishing-directory "./public/cosmicflow-gmi"
:recursive t
:publishing-function org-gemini-publish-to-gemini
:with-author nil
:with-creator nil
:email nil
:with-timestamps nil)
;; ("cosmicpirates-gmi-static"
;; :base-directory "./content/static"
;; :base-extension "css\\|ttf\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|xml\\|html"
;; :publishing-directory "./public/cosmicpirates.space-gmi/static"
;; :recursive t
;; :publishing-function org-publish-attachment
;; export txt file as txt file in org html website publish
;; )
)
)
;; (defun my/publish ()
;; "Publish the entire site."
;; (interactive)
;; (org-publish-all (string-equal (or (getenv "FORCE")
;; (getenv "CI"))
;; "true"))
;; (webfeeder-build "rss/news.xml"
;; "./public"
;; my/site-url
;; (let ((default-directory (expand-file-name "./public/")))
;; (remove "news/index.html"
;; (directory-files-recursively "news"
;; ".*\\.html$")))
;; :builder 'webfeeder-make-rss
;; :title "cosmiflow news"
;; :description "News and Insights from Cosmicflow!"
;; :author "Dibyashanu Pati")
;; )
;; publish the websites
(org-publish-all t)
(message "Build complete!")