From 2eaa1e26e7aa9ffe66463352026b1d27ac3276fb Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 13 Jun 2026 19:22:35 +0300 Subject: added an index for the blog --- blog/index.org | 65 ++++++++++++++ blog/post.org | 2 + generated/blog/index.html | 223 ++++++++++++++++++++++++++++++++++++++++++++++ generated/blog/post.html | 8 +- 4 files changed, 296 insertions(+), 2 deletions(-) create mode 100644 blog/index.org create mode 100644 generated/blog/index.html diff --git a/blog/index.org b/blog/index.org new file mode 100644 index 0000000..62167c8 --- /dev/null +++ b/blog/index.org @@ -0,0 +1,65 @@ +#+TITLE: Blogin sisällys + +#+begin_src emacs-lisp :exports results + + (defun get-org-file-property (path property) + "Gets PROPERTY of org file at PATH. Returns nil if not found." + (with-temp-buffer (setq case-fold-search t) + (insert-file-contents path) + (if (search-forward (concat "#+" property ":") nil t) + (string-trim-left (buffer-substring (point) (line-end-position))) + nil))) + + (defun get-org-file-title (name) + "Gets the title of the org file. Returns nil if not found." + (get-org-file-property name "TITLE")) + + (defun get-file-date (path) + "Gets the date of the file at PATH. + For an Org file where the date option is specified, it is used. + Otherwise the file modification date is used. + The date is returned in textual form, YYYY-MM-DD." + (or (if (string= (file-name-extension path) "org") + (get-org-file-property path "DATE") + nil) + (format-time-string "%Y-%m-%d" + (file-attribute-modification-time + (file-attributes (concat "./" name)))))) + + (defun generate-entry + (name) + "Generates an index entry for file NAME." + (let ((extension (file-name-extension name)) (bname (file-name-sans-extension name))) + (concat "[[./" + name + "][" + (or + (if (string= extension "org") + (get-org-file-title (concat "./" name)) + nil) + bname) + "]] (" + (get-file-date (concat "./" name)) + ") " + (or (if (string= extension "org") + (get-org-file-property (concat "./" name) "SUBTITLE") + nil) + "Alaotsikkoa ei saatavilla")))) + + (let ((files + (seq-filter (lambda (name) + (not (or + (string-suffix-p "~" name) + (string-suffix-p "#" name) + (string-prefix-p "#" name) + (string-prefix-p "." name) + (string= "index.org" name)))) + (directory-files "./")))) + (seq-map (lambda (name) `(,(generate-entry name))) files)) +#+end_src + +#+RESULTS: +| [[./post.org][Test-post-title]] (2026-06-12) Test subtitle | +| [[./tekstinsyotto.html][tekstinsyotto]] (2025-07-28) Alaotsikkoa ei saatavilla | +| [[./yksinkertaisesti-monipuolinen.txt][yksinkertaisesti-monipuolinen]] (2024-05-06) Alaotsikkoa ei saatavilla | + diff --git a/blog/post.org b/blog/post.org index b01a6c8..3f385cd 100644 --- a/blog/post.org +++ b/blog/post.org @@ -1,3 +1,5 @@ +#+TITLE: Test-post-title +#+SUBTITLE: Test subtitle * Test post diff --git a/generated/blog/index.html b/generated/blog/index.html new file mode 100644 index 0000000..13557a1 --- /dev/null +++ b/generated/blog/index.html @@ -0,0 +1,223 @@ + + + + + + + +Blogin sisällys + + + + + + +
+

Blogin sisällys

+ + + +++ + + + + + + + + + + + + + +
Test-post-title (2026-06-12) Test subtitle
tekstinsyotto (2025-07-28) Alaotsikkoa ei saatavilla
yksinkertaisesti-monipuolinen (2024-05-06) Alaotsikkoa ei saatavilla
+
+ + diff --git a/generated/blog/post.html b/generated/blog/post.html index d615cd4..2605de8 100644 --- a/generated/blog/post.html +++ b/generated/blog/post.html @@ -3,10 +3,10 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + - +Test-post-title