Adds dates, fixes orders of posts

This commit is contained in:
2024-10-13 17:15:21 -04:00
parent 11cb9f387e
commit 54961ebd1e
3 changed files with 252 additions and 185 deletions

View File

@@ -10,7 +10,7 @@
(pico-fluid . "https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.fluid.classless.min.css")
(pico . "https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css")))
(setq wfot-css (alist-get 'pico-amber wfot-styles))
(setq primary-css (alist-get 'pico-amber wfot-styles))
(defun wfot-default (page-tree pages _global)
"willfullyobtuse default render function
@@ -28,7 +28,8 @@
`(:html
(:head
(:meta (@ :name "viewport" :content "width=device-width,initial-scale=1"))
(:link (@ :rel "stylesheet" :href wfot-css))
(:link (@ :rel "stylesheet" :href primary-css))
(:link (@ :rel "stylesheet" :href "wfot.css"))
(:title ,title))
(:body
(:header (:a (@ :href "/") ,website-name))
@@ -51,13 +52,14 @@ Also see `one-render-pages' and `one-default-css'."
'one-ox nil))
(website-name (one-default-website-name pages))
;; All pages but the home pages
(pages-list (one-default-pages pages "/.+")))
(pages-list (wfot-default-pages pages "/.+")))
(jack-html
"<!DOCTYPE html>"
`(:html
(:head
(:meta (@ :name "viewport" :content "width=device-width,initial-scale=1"))
(:link (@ :rel "stylesheet" :type "text/css" :href wfot-css))
(:link (@ :rel "stylesheet" :href primary-css))
(:link (@ :rel "stylesheet" :href "wfot.css"))
(:title ,title))
(:body
(:header (:a (@ :href "/") ,website-name))
@@ -65,6 +67,52 @@ Also see `one-render-pages' and `one-default-css'."
(:div/home-list-pages ,content)
(:div/pages (:ul ,(reverse pages-list)))))))))
(defun wfot-default-pages (pages &optional filter)
"Return `jack-html' list of PAGES component.
If FILTER is non-nil, a page is listed only when its path (value
of `:one-path' property) matches FILTER regexp.
Evaluating the following form
(wfot-default-pages
\\='((:one-title \"HOME\" :one-path \"/\")
(:one-title \"FOO-1\" :one-path \"/foo-1/\")
(:one-title \"FOO-2\" :one-path \"/foo-2/\")))
returns:
(:ul
(:li (:a (@ :href \"/\") \"HOME\"))
(:li (:a (@ :href \"/foo-1/\") \"FOO-1\"))
(:li (:a (@ :href \"/foo-2/\") \"FOO-2\")))
And evaluating the following form with the filter \"/.+\"
(wfot-default-pages
\\='((:one-title \"HOME\" :one-path \"/\")
(:one-title \"FOO-1\" :one-path \"/foo-1/\")
(:one-title \"FOO-2\" :one-path \"/foo-2/\"))
\"/.+\")
returns a list which doesn't include the home page:
(:ul
(:li (:a (@ :href \"/foo-1/\") \"FOO-1\"))
(:li (:a (@ :href \"/foo-2/\") \"FOO-2\")))"
(when-let ((li-items
(delq nil
(mapcar
(lambda (page)
(let ((href (plist-get page :one-path))
(title (plist-get page :one-title))
(date (org-element-property :DATE (plist-get page :one-page-tree))))
(when (string-match-p (or filter ".*") href)
`(:li (@ :class "post-item") (:div (@ :class "post-date") ,date) (:a (@ :href ,href) (:span ,title)) ))))
pages))))
`(:ul ,@li-items)))
(defun wfot-default-home (page-tree pages _global)
"Default render function to use in the home page.
@@ -81,7 +129,8 @@ Also see `one-render-pages' and `one-default-css'."
`(:html
(:head
(:meta (@ :name "viewport" :content "width=device-width,initial-scale=1"))
(:link (@ :rel "stylesheet" :type "text/css" :href wfot-css))
(:link (@ :rel "stylesheet" :href primary-css))
(:link (@ :rel "stylesheet" :href "wfot.css"))
(:title ,title))
(:body
(:header ,website-name)
@@ -108,14 +157,14 @@ in the HTML string.
This function is meant to be used by `one-default-with-sidebar'
and `one-default-doc' render functions.
See `one-render-pages', `one-default-css' and `one-default-pages'."
See `one-render-pages', `one-default-css' and `wfot-default-pages'."
(let* ((title (org-element-property :raw-value page-tree))
(path (org-element-property :CUSTOM_ID page-tree))
(content (org-export-data-with-backend
(org-element-contents page-tree)
'one-ox nil))
(website-name (one-default-website-name pages))
(pages-list (one-default-pages pages))
(pages-list (wfot-default-pages pages))
(headlines (cdr (one-default-list-headlines page-tree)))
(toc (one-default-toc-component headlines))
(nav (one-default-nav path pages)))
@@ -124,7 +173,8 @@ See `one-render-pages', `one-default-css' and `one-default-pages'."
`(:html
(:head
(:meta (@ :name "viewport" :content "width=device-width,initial-scale=1"))
(:link (@ :rel "stylesheet" :type "text/css" :href wfot-css))
(:link (@ :rel "stylesheet" :href primary-css))
(:link (@ :rel "stylesheet" :href "wfot.css"))
(:title ,title))
(:body
;; sidebar-left and sidebar-main are for small devices