Skip to content

Commit 0e97df1

Browse files
author
Adam Simpson
committed
feat: generate now produces a proper slug if given a normal title
1 parent 44729e7 commit 0e97df1

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ ecl:
88
clean:
99
rm cycle
1010
.PHONY: cycle
11+
12+
install:
13+
mv cycle /usr/local/bin/cycle
14+
.PHONY: install

cycle.asd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
:description "A opinionated static site builder."
55
:author "Adam Simpson <adam@adamsimpson.net>"
66
:license "GNU GPLv3"
7-
:version "0.2.1"
7+
:version "0.2.6"
88
:serial t
99
:depends-on (
1010
:local-time
1111
:cl-json
1212
:cl-mustache
13+
:cl-ppcre
1314
:3bmd
1415
:3bmd-ext-code-blocks
1516
:unix-opts)

cycle.lisp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,13 @@
303303

304304
(defun generate-post (title)
305305
"Take TITLE and create the necessary JSON and MD files for it."
306-
(let ((date (shell "date +%Y-%m-%dT%R:%S%:z"))
306+
(let* ((date (shell "date +%Y-%m-%dT%R:%S%:z"))
307+
(slug (cl-ppcre:regex-replace-all ","
308+
(cl-ppcre:regex-replace-all " " (string-downcase title) "-")
309+
""))
307310
(id (get-id))
308-
(json-file (concat "./posts/" title ".json"))
309-
(md-file (concat "./posts/" title ".md")))
311+
(json-file (concat "./posts/" slug ".json"))
312+
(md-file (concat "./posts/" slug ".md")))
310313
(write-file (json:encode-json-to-string `(("id" . ,id)
311314
("published" . ,date)
312315
("title" . ,title)

0 commit comments

Comments
 (0)