pages.scm 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. (define-module (builders pages)
  2. #:use-module (theme theme)
  3. #:use-module (haunt site)
  4. #:use-module (haunt post)
  5. #:use-module (haunt page)
  6. #:use-module (haunt html)
  7. #:use-module (haunt utils)
  8. #:use-module (utils utils)
  9. #:declarative? #f
  10. #:export (pages))
  11. ;; my pages builder cannot render pages the same way that my-blog
  12. ;; builder does. my blog builder renders posts, because it gets a
  13. ;; list of posts. However, my pages are NOT posts.
  14. ;; Builders are procedures that return one or more page objects (*note
  15. ;; Pages::) when applied. A builder accepts two arguments: A site
  16. ;; (*note Sites:: and a list of posts (*note Posts::).
  17. (define (pages)
  18. (lambda (site posts)
  19. (flatten
  20. ;; this loops through all the files in my site's pages directory
  21. ;; and outputs the appropriate style.
  22. (let loop ([pages (files-in-dir "./pages")])
  23. (if (null? pages)
  24. '()
  25. (cons
  26. (let* ([current-sxml-file (car pages)]
  27. [current-filename (string-drop-right current-sxml-file 4)]
  28. [destination-file (string-append current-filename "html")]
  29. [title (string-upcase (string-drop-right current-sxml-file 5) 0 1)])
  30. (make-page destination-file
  31. (gnucode-layout site title
  32. (load (string-append "../pages/" current-sxml-file)))
  33. sxml->html))
  34. (loop (cdr pages))))))))