diff options
Diffstat (limited to 'fi/blog/index.org')
| -rw-r--r-- | fi/blog/index.org | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/fi/blog/index.org b/fi/blog/index.org new file mode 100644 index 0000000..62167c8 --- /dev/null +++ b/fi/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 | + |
