-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme.scm
More file actions
120 lines (113 loc) · 5.67 KB
/
theme.scm
File metadata and controls
120 lines (113 loc) · 5.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
(define-module (theme)
#:use-module (ice-9 match)
#:use-module (srfi srfi-19) ; dates
#:use-module (rnrs bytevectors)
#:use-module (haunt site)
#:use-module (haunt post)
#:use-module (haunt utils)
#:use-module (haunt builder blog)
#:use-module (utils)
#:export (trqt-theme))
(define %copyright #vu8(194 169))
(define %right-arrow #vu8(226 134 146))
;; 0xe2 0x84 0xa2
(define %cc-by-sa-button
'(a (@ (class "cc-button")
(href "https://creativecommons.org/licenses/by-sa/4.0/"))
(img (@ (src "https://licensebuttons.net/l/by-sa/4.0/80x15.png")))))
(define (stylesheet name)
"Link a stylesheet by stylesheet NAME to its corresponding file in /css/ directory"
`(link (@ (rel "stylesheet")
(href ,(string-append "/css/" name ".css")))))
(define (javascript name)
"Link a Javascript file by NAME to its file in the built /js/ directory."
`(script (@ (src ,(string-append "/js/" name)))))
(define trqt-theme
(theme #:name "trqt-theme"
#:layout
(lambda (site title body)
`((doctype "html")
(html (@ (lang "en"))
(head
(meta (@ (charset "utf-8")))
(meta (@ (name "description")
(content "Guilherme Torquato's web portal")))
(link (@ (rel "icon")
(type "image/x-icon")
(href "/assets/favicon/favicon.ico")))
(link (@ (rel "alternate")
(type "application/atom+xml")
(title "trqt Atom Feed")
(href "/feed.xml")))
(meta (@ (name "viewport")
(content "width=device-width, initial-scale=1.0")))
(meta (@ (name "color-scheme")
(content ,(string-join
;; Page supports dark & light, and author
;; prefers dark.
(list "dark" "light")))))
(meta (@ (property "og:title")
(content ,title)))
(meta (@ (name "og:author")
(content ,(assoc-ref (site-default-metadata site) 'author))))
(title ,title)
;; ,(stylesheet "core")
;; Main body of the particular page we are on
(body
;; Setup navigation (shared between all pages)
(div (@ (class "container"))
(nav (@ (class "site-navigation")
(id "site-navigation")
(aria-labelledby "site-navigation"))
(menu (@ (class "nav-brand"))
(li ,(link "trqt" "/"))
)
(menu (@ (class "nav-headers"))
(li ,(link "Blog" "/blog"))
;; (li ,(link "CV" "/resume"))
;; (li ,(link "CTFs" "/ctf"))
(li ,(link "GitHub" "https://github.com/trqt"))))
;; The body of the page tree is rendered and remains unchanged
(header (@ (class "page-title"))
(h1 ,title))
,body
;; The footer of the page
(footer (@ (style "text-align: center;"))
(hr)
(p "Built using " ,(link "Guile" "https://www.gnu.org/software/guile/")
", " ,(link "Emacs" "https://www.gnu.org/software/emacs/")
", and " ,(link "Haunt" "https://dthompson.us/projects/haunt.html"))
(a (@ (rel "license")
(href "http://creativecommons.org/licenses/by-sa/4.0/"))
,%cc-by-sa-button
" by "
(a (@ (xmlns:cc "http://creativecommons.org/ns#")
(property "cc:attributionName")
(rel "cc:attributionURL")
(href "http://trqt.github.io"))
"Guilherme Torquato"))
)))))))
;; How to layout an individual post from my blog
#:post-template
(lambda (post)
`((hgroup
,(post-html-datetime post)
,(post-tags-sxml post))
(article
,(post-sxml post))))
;; How to layout the collection page for my blog
#:collection-template
(lambda (site title posts prefix)
`(,(map (lambda (post)
(let ((uri (string-append "/blog/" ;; TODO: better way to get prefix
(site-post-slug site post)
".html")))
`(article
(h2 (a (@ (href ,uri))
,(post-ref post 'title)))
,(post-html-datetime post)
(div (@ (class "post"))
,(post-ref post 'summary))
(a (@ (href ,uri)) "read more "
,(utf8->string %right-arrow)))))
posts)))))