Commit d66eb846 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

org: better sitemap

* doc/org/ List pages in a nested list according to
parent 89792597
Pipeline #8640 passed with stages
in 124 minutes and 34 seconds
...@@ -110,11 +110,43 @@ ...@@ -110,11 +110,43 @@
(setq org-html-table-header-tags (setq org-html-table-header-tags
'("<th scope=\"%s\"%s><div><span>" . "</span></div></th>")) '("<th scope=\"%s\"%s><div><span>" . "</span></div></th>"))
(defun spot-publish-sitemap (title list) (defun spot-sitemap-format-entry (entry style project)
"Same as org-publish-sitemap-default except it adds the SETUPFILE." "Export a sitemap entry in a why that we can order them meaningfully.
(concat "#+TITLE: " title If file ENTRY has HTML_LINK_UP pointing to file up.html, and file
"\n#+SETUPFILE:\n#+HTML_LINK_UP: index.html\n\n" up.html points to index.html, then the result is:
(org-list-to-org list))) [[][TITLE]]"
(let ((linkup (org-publish-find-property entry :html-link-up project 'html))
(trail (concat entry "/ ")))
(while (and linkup (string-match "^\\(.*\\)\.html$" linkup))
(let ((match (concat (match-string 1 linkup) ".org")))
(if (string= match entry)
(setq linkup nil)
(setq linkup (org-publish-find-property match :html-link-up
project 'html)
trail (concat match "/" trail)))))
(concat trail (org-publish-sitemap-default-entry entry style project))))
(defun spot-sitemap-reorder (entries)
(sort entries (lambda (a b) (string< (car a) (car b)))))
(defun spot-publish-sitemap (title thelist)
"Build Spot's sitemap.
This is done by sorting all lines, and then replacing
- [[][TITLE]]
- [[][TITLE]]
but indented according to the number of 'fake directory' parts."
(let ((body (org-list-to-org (cons 'unordered
(spot-sitemap-reorder (cdr thelist))))))
(let* ((res (replace-regexp-in-string "\\([:space:]*\\)- [^/[:space:]]+/" " \\1- " body))
(cmp (string= res body)))
(setq body res)
(not cmp)))
(concat "#+TITLE: " title
"\n#+SETUPFILE:\n#+HTML_LINK_UP: index.html\n\n"
(setq org-publish-project-alist (setq org-publish-project-alist
'(("spot-html" '(("spot-html"
...@@ -126,6 +158,7 @@ ...@@ -126,6 +158,7 @@
:auto-sitemap t :auto-sitemap t
:sitemap-title "Sitemap for Spot" :sitemap-title "Sitemap for Spot"
:sitemap-function spot-publish-sitemap :sitemap-function spot-publish-sitemap
:sitemap-format-entry spot-sitemap-format-entry
:publishing-function org-html-publish-to-html :publishing-function org-html-publish-to-html
:html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"spot.css\" />" :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"spot.css\" />"
:auto-preamble t) :auto-preamble t)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment