Recently Written · git

coleslaw

Emacs mode for the "Coleslaw" site generator written in Common Lisp.

git clone https://github.com/equwal/coleslaw

Log | Files | Refs


commit efc0bfb738a435689497914407b3f49a297b41a4
Spenser Truex <web@spensertruex.com>
2020-03-24 15:51:54 -0700

Support name-fn for modifying URL strings.

Once the title has been converted to a URL (by `slugify`), name-fn changes it.
It is available in the .coleslawrc as `:namefn 'fn`, with the default
`:name-fn 'identity`

 src/config.lisp    | 2 ++
 src/documents.lisp | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/config.lisp b/src/config.lisp
index 53f0fe4..92a1164 100644
--- a/src/config.lisp
+++ b/src/config.lisp
@@ -7,6 +7,7 @@
    (domain          :initarg :domain         :reader domain)
    (excerpt-sep     :initarg :excerpt-sep    :reader excerpt-sep)
    (feeds           :initarg :feeds          :reader feeds)
+   (name-fn         :initarg :name-fn        :reader name-fn)
    (lang            :initarg :lang           :reader lang)
    (license         :initarg :license        :reader license)
    (page-ext        :initarg :page-ext       :reader page-ext-intolerant)
@@ -25,6 +26,7 @@
    :plugins      '((rsync "-avz" "--delete" "--exclude" ".git/" "--exclude" ".gitignore" "--copy-links"))
    :sitenav      nil
    :excerpt-sep  "<!--more-->"
+   :name-fn      'identity
    :charset      "UTF-8"
    :lang         "en"
    :page-ext     #1="html"
diff --git a/src/documents.lisp b/src/documents.lisp
index 0bb64c6..225b836 100644
--- a/src/documents.lisp
+++ b/src/documents.lisp
@@ -42,7 +42,8 @@ is provided, it overrides the route used."
       (error "No routing method found for: ~A" class-name))
     (let* ((result (format nil route unique-id))
            (type (or (pathname-type result) (page-ext *config*))))
-      (make-pathname :name (pathname-name result)
+      (make-pathname :name (funcall (name-fn *config*)
+                                    (pathname-name result))
                      :type (when (string/= type "")
                              (if (or (string-equal "index"
                                                    (pathname-name result))