Line | |
---|
1 | #+TITLE: @w96k: Кириллов Михаил
|
---|
2 | #+OPTIONS: toc:nil
|
---|
3 |
|
---|
4 | * Посты
|
---|
5 |
|
---|
6 | #+BEGIN_SRC emacs-lisp :exports results :results html
|
---|
7 | (defun read-lines (filePath)
|
---|
8 | "Return a list of lines of a file at filePath."
|
---|
9 | (with-temp-buffer
|
---|
10 | (insert-file-contents filePath)
|
---|
11 | (split-string (buffer-string) "\n" t)))
|
---|
12 |
|
---|
13 | ;; Sort by modified date
|
---|
14 | (setq list-of-posts (sort (directory-files-and-attributes "./posts" nil ".org$")
|
---|
15 | #'(lambda (x y) (time-less-p (nth 6 y) (nth 6 x)))))
|
---|
16 |
|
---|
17 | (defun make-links (str)
|
---|
18 | (setq file-name (car str))
|
---|
19 | (setq str-link (s-replace ".org" ".html" file-name))
|
---|
20 | ;; We make an assumption, that #+TITLE is on first line
|
---|
21 | (setq article-title (s-replace "#+TITLE: " "" (car (read-lines (concat "posts/" file-name)))))
|
---|
22 | (concat "<li><a href=\"/posts/" str-link "\">" article-title "</a></li>"))
|
---|
23 |
|
---|
24 | (concat "<ul>" (mapconcat 'make-links list-of-posts "\n") "</ul>")
|
---|
25 | #+END_SRC
|
---|
Note:
See
TracBrowser
for help on using the repository browser.