From a760bff3efa44c282ed119032a6831bdaac79e7b Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 7 Apr 2025 15:57:53 +0100 Subject: Initial commit --- pandoc-blog/make.scm | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 pandoc-blog/make.scm (limited to 'pandoc-blog/make.scm') diff --git a/pandoc-blog/make.scm b/pandoc-blog/make.scm new file mode 100644 index 0000000..1c9728c --- /dev/null +++ b/pandoc-blog/make.scm @@ -0,0 +1,47 @@ +(use-modules ((gnu packages haskell-xyz) #:select (pandoc)) + ((gnu packages python) #:select (python)) + (guix build utils) + (guix gexp)) + +(define (build-post post) + (computed-file (basename post ".md") + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + (let ((posts-directory (string-append #$output "/posts/"))) + (mkdir-p posts-directory) + (invoke #$(file-append pandoc "/bin/pandoc") + "--from" "markdown" + "--to" "html" + "--standalone" + "--output" (string-append posts-directory + #$(basename post ".md") + ".html") + #$(local-file post))))))) + +(define (build-index posts) + (computed-file "blog-index" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + (invoke #$(file-append python "/bin/python3") + #$(local-file "generate-index.py") + "index.md" + #$@(map (lambda (file) + (local-file file)) + posts)) + (mkdir #$output) + (invoke #$(file-append pandoc "/bin/pandoc") + "--from" "markdown" + "--to" "html" + "--standalone" + "--metadata" "title=My blog" + "--output" (string-append #$output "/index.html") + "index.md"))))) + +(let ((posts (find-files "posts" "\\.md$"))) + (directory-union "blog" + (cons (build-index posts) + (map build-post posts)))) -- cgit v1.2.3