theme.scm 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. (define-module (theme theme)
  2. #:use-module (srfi srfi-19)
  3. #:use-module (haunt site)
  4. #:use-module (haunt post)
  5. #:use-module (utils utils)
  6. #:export (gnucode-layout
  7. date->string*
  8. %meta-sxml-elements
  9. %header-sxml-element
  10. %footer-sxml
  11. %sxml-css-links))
  12. (define (date->string* date)
  13. "Convert DATE to human readable string."
  14. (date->string date "~B ~d, ~Y"))
  15. (define (gnucode-layout site title body)
  16. `((doctype "html")
  17. (head
  18. ,%meta-sxml-elements
  19. ,%sxml-css-links
  20. (title ,(string-append title " — " (site-title site))))
  21. (body
  22. ,%header-sxml-element
  23. ,(if (string=? "Recent Posts" title)
  24. `(h1 ,(site-title site))
  25. `(h1 ,title))
  26. (main
  27. ,body)
  28. ,%footer-sxml
  29. )))
  30. (define %header-sxml-element
  31. `((header
  32. (nav
  33. (ul
  34. (li (a (@ (href "index.html")) "GNUcode.me"))
  35. ,(let loop ([pages (files-in-dir "/home/joshua/prog/gnu/guile/gnucode.me/pages/")])
  36. (define current-page-name (if (null? pages)
  37. '()
  38. (string-drop-right (car pages) 5)))
  39. (if (null? pages)
  40. '()
  41. (cons
  42. `(li (a (@ (href
  43. ,(string-append current-page-name ".html")))
  44. ,(string-upcase current-page-name 0 1)
  45. ))
  46. (loop (cdr pages)))))
  47. )))))
  48. (define %sxml-css-links
  49. '(
  50. (link (@ (type "text/css") (href "css/footer.min.css") (rel "stylesheet")) "")
  51. (link (@ (type "text/css") (href "css/header.min.css") (rel "stylesheet")) "")
  52. (link (@ (type "text/css") (href "css/main.min.css") (rel "stylesheet")) "")
  53. ))
  54. (define %meta-sxml-elements
  55. '(
  56. (meta (@ (charset "utf-8")))
  57. (meta (@ (name "viewport") (content "width=device-width, initial-scale=1, shrink-to-fit=no")))
  58. (meta (@ (name "keywords") (content "GNU, Emacs, Libre Software, Hurd, Guile, Guix")))
  59. (meta (@ (name "description")
  60. (content "GNUcode.me is a website focusing on libre software projects, especially the GNU project.")))
  61. (link (@ (type "application/atom+xml") (rel "alternate") (title "GNUcode.me -- Feed")
  62. (href "/feed.xml")))
  63. (a (@ (rel "me") (href "https://fosstodon.org/@thegnuguy")) "")
  64. ))
  65. (define %footer-sxml
  66. '(footer
  67. (p "© 2020 Joshua Branson. The text on this site is free culture under the Creative Commons Attribution Share-Alike 4.0 International license.")
  68. (p "This website is build with Haunt, a static site generator written in Guile Scheme. Source code is "
  69. (a (@ (href "https://notabug.org/jbranso/gnucode.me")) "available."))
  70. (p "The color theme of this website is based off of the famous "
  71. (a (@ (href "#3f3f3f") (target "_blank")) "zenburn")
  72. " theme.")))