@@ -19,6 +19,10 @@
|
||||
<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z\"/><rect x=\"2\" y=\"9\" width=\"4\" height=\"12\"/><circle cx=\"4\" cy=\"4\" r=\"2\"/></svg>
|
||||
linkedin.com/in/aner-zakobar
|
||||
</a>
|
||||
<a href=\"/feed.xml\" class=\"contact-link\">
|
||||
<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M4 11a9 9 0 0 1 9 9\"/><path d=\"M4 4a16 16 0 0 1 16 16\"/><circle cx=\"5\" cy=\"19\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/></svg>
|
||||
RSS
|
||||
</a>
|
||||
</div>")
|
||||
|
||||
(setq blog-nav
|
||||
@@ -61,9 +65,69 @@
|
||||
"</div>\n")))))
|
||||
(insert "</div>\n#+END_EXPORT\n"))))
|
||||
|
||||
(defun blog-escape-xml (str)
|
||||
"Escape XML special characters in STR."
|
||||
(let ((s (or str "")))
|
||||
(setq s (replace-regexp-in-string "&" "&" s))
|
||||
(setq s (replace-regexp-in-string "<" "<" s))
|
||||
(setq s (replace-regexp-in-string ">" ">" s))
|
||||
s))
|
||||
|
||||
(defun blog-date-to-rfc822 (date-str)
|
||||
"Convert YYYY-MM-DD string to RFC 822 format."
|
||||
(let* ((parts (split-string date-str "-"))
|
||||
(year (string-to-number (nth 0 parts)))
|
||||
(month (string-to-number (nth 1 parts)))
|
||||
(day (string-to-number (nth 2 parts)))
|
||||
(month-names '("Jan" "Feb" "Mar" "Apr" "May" "Jun"
|
||||
"Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
|
||||
(day-names '("Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"))
|
||||
(time (encode-time 0 0 0 day month year))
|
||||
(decoded (decode-time time))
|
||||
(dow (nth 6 decoded)))
|
||||
(format "%s, %02d %s %04d 00:00:00 +0000"
|
||||
(nth dow day-names)
|
||||
day
|
||||
(nth (1- month) month-names)
|
||||
year)))
|
||||
|
||||
(defun blog-generate-rss (_project)
|
||||
"Write public/feed.xml from all blog posts."
|
||||
(let* ((blog-dir "./content/blog")
|
||||
(base-url "https://aner.zakobar.com")
|
||||
(pattern (concat blog-dir "/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-*.org"))
|
||||
(files (sort (file-expand-wildcards pattern t)
|
||||
(lambda (a b) (string> (file-name-base a)
|
||||
(file-name-base b))))))
|
||||
(make-directory "./public" t)
|
||||
(with-temp-file "./public/feed.xml"
|
||||
(insert "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
||||
(insert "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n")
|
||||
(insert " <channel>\n")
|
||||
(insert " <title>Aner Zakobar</title>\n")
|
||||
(insert (format " <link>%s</link>\n" base-url))
|
||||
(insert " <description>Personal blog of Aner Zakobar</description>\n")
|
||||
(insert (format " <atom:link href=\"%s/feed.xml\" rel=\"self\" type=\"application/rss+xml\"/>\n" base-url))
|
||||
(dolist (file files)
|
||||
(let* ((base (file-name-base file))
|
||||
(date (substring base 0 10))
|
||||
(title (blog-escape-xml (blog-extract-title file)))
|
||||
(excerpt (blog-escape-xml (blog-extract-excerpt file)))
|
||||
(url (format "%s/blog/%s.html" base-url base)))
|
||||
(insert " <item>\n")
|
||||
(insert (format " <title>%s</title>\n" title))
|
||||
(insert (format " <link>%s</link>\n" url))
|
||||
(insert (format " <guid>%s</guid>\n" url))
|
||||
(insert (format " <pubDate>%s</pubDate>\n" (blog-date-to-rfc822 date)))
|
||||
(insert (format " <description>%s</description>\n" excerpt))
|
||||
(insert " </item>\n")))
|
||||
(insert " </channel>\n")
|
||||
(insert "</rss>\n"))))
|
||||
|
||||
(defun site-prepare (project)
|
||||
"Run all site preparation steps."
|
||||
(blog-generate-listings project)
|
||||
(blog-generate-rss project)
|
||||
(things-generate-page project))
|
||||
|
||||
(defun blog-extract-title (file)
|
||||
@@ -140,7 +204,7 @@
|
||||
:preparation-function site-prepare
|
||||
:html-head-include-default-style nil
|
||||
:html-head-include-scripts nil
|
||||
:html-head "<link rel=\"stylesheet\" href=\"/style.css\"><script src=\"/animation.js\" defer></script>"
|
||||
:html-head "<link rel=\"stylesheet\" href=\"/style.css\"><script src=\"/animation.js\" defer></script><link rel=\"alternate\" type=\"application/rss+xml\" title=\"Aner Zakobar\" href=\"/feed.xml\">"
|
||||
:html-preamble ,site-nav
|
||||
:html-postamble nil
|
||||
:with-author nil
|
||||
@@ -157,7 +221,7 @@
|
||||
:publishing-function org-html-publish-to-html
|
||||
:html-head-include-default-style nil
|
||||
:html-head-include-scripts nil
|
||||
:html-head "<link rel=\"stylesheet\" href=\"/style.css\"><script src=\"/animation.js\" defer></script>"
|
||||
:html-head "<link rel=\"stylesheet\" href=\"/style.css\"><script src=\"/animation.js\" defer></script><link rel=\"alternate\" type=\"application/rss+xml\" title=\"Aner Zakobar\" href=\"/feed.xml\">"
|
||||
:html-preamble ,blog-nav
|
||||
:html-postamble nil
|
||||
:with-author nil
|
||||
|
||||
Reference in New Issue
Block a user