Changeset d55e988 for content/index.org


Ignore:
Timestamp:
Jan 5, 2020, 11:18:36 PM (5 years ago)
Author:
Mikhail Kirillov <w96k@…>
Branches:
master
Children:
d829433
Parents:
90e0d35
git-author:
Mikhail Kirillov <w96k@…> (01/05/20 22:47:38)
git-committer:
Mikhail Kirillov <w96k@…> (01/05/20 23:18:36)
Message:

Add posts on index page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • content/index.org

    r90e0d35 rd55e988  
    1 #+TITLE: @w96k
     1#+TITLE: @w96k: Кириллов Михаил
    22#+OPTIONS: toc:nil
    33
    44* Посты
    55
    6 #+BEGIN_SRC emacs-lisp :exports results :results raw
    7 (+ 3 2)
     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>")
    825#+END_SRC
Note: See TracChangeset for help on using the changeset viewer.