|
8 | 8 | racket/match |
9 | 9 | racket/path |
10 | 10 | racket/promise |
11 | | - racket/runtime-path |
12 | 11 | racket/sequence |
13 | | - (only-in megaparsack parse-result!) |
14 | | - (only-in megaparsack/text parse-string) |
15 | | - (only-in scribble/base title) |
16 | 12 | scribble/base-render |
17 | | - (only-in scribble/core document-date style) |
18 | 13 | scribble/xref |
19 | 14 | setup/xref |
20 | 15 | threading |
21 | 16 | (only-in xml write-xexpr) |
22 | 17 |
|
23 | | - (only-in "markdown/parse.rkt" document/p) |
24 | 18 | "markdown/post.rkt" |
25 | | - "markdown/to-scribble.rkt" |
26 | 19 | "paths.rkt" |
27 | | - "lang/metadata.rkt" |
28 | 20 | "build/metadata.rkt" |
29 | 21 | "build/render/scribble.rkt" |
30 | 22 | "build/render/page.rkt") |
|
143 | 135 | out-path |
144 | 136 | (λ~>> (write-html (post-page info))))) |
145 | 137 |
|
146 | | -(define (build-post-index total-pages number deps+infos) |
| 138 | +(define (build-post-index total-pages number posts) |
147 | 139 | (define base-path (index-path number #:file? #t)) |
148 | 140 | (define out-path (reroot-path base-path output-dir)) |
149 | 141 | (eprintf "~a rendering <output>~a\n" (timestamp-string) base-path) |
150 | | - (define paths+infos (for/list ([dep+info (in-list deps+infos)]) |
151 | | - (match-define (list dep info) dep+info) |
152 | | - (list (output-path->absolute-url (post-dep-page-path dep)) info))) |
153 | 142 | (call-with-output-file* #:exists 'truncate/replace |
154 | 143 | out-path |
155 | | - (λ~>> (write-html (post-index-page total-pages number paths+infos))))) |
| 144 | + (λ~>> (write-html (post-index-page total-pages number posts))))) |
156 | 145 |
|
157 | | -(define (build-tag-index total-pages page-number tag deps+infos) |
| 146 | +(define (build-tag-index total-pages page-number tag posts) |
158 | 147 | (define base-path (tag-index-path tag page-number)) |
159 | 148 | (define out-path (reroot-path base-path output-dir)) |
160 | 149 | (eprintf "~a rendering <output>~a\n" (timestamp-string) base-path) |
161 | | - (define paths+infos (for/list ([dep+info (in-list deps+infos)]) |
162 | | - (match-define (list dep info) dep+info) |
163 | | - (list (output-path->absolute-url (post-dep-page-path dep)) info))) |
164 | 150 | (make-parent-directory* out-path) |
165 | 151 | (call-with-output-file* #:exists 'truncate/replace |
166 | 152 | out-path |
167 | | - (λ~>> (write-html (tag-index-page total-pages page-number tag paths+infos))))) |
| 153 | + (λ~>> (write-html (tag-index-page total-pages page-number tag posts))))) |
168 | 154 |
|
169 | 155 | (define (build-all) |
170 | 156 | (make-directory* build-dir) |
|
176 | 162 | info)) |
177 | 163 |
|
178 | 164 | (define total-pages (ceiling (/ (length all-post-deps) num-posts-per-page))) |
179 | | - (for ([deps+infos (in-slice num-posts-per-page (reverse (map list all-post-deps post-infos)))] |
| 165 | + (for ([posts (in-slice num-posts-per-page (reverse post-infos))] |
180 | 166 | [number (in-naturals 1)]) |
181 | | - (build-post-index total-pages number deps+infos)) |
182 | | - |
183 | | - (define tagged-deps+infos |
184 | | - (for/fold ([tagged-deps+infos (hash)]) |
185 | | - ([dep (in-list all-post-deps)] |
186 | | - [info (in-list post-infos)] |
187 | | - #:when #t |
188 | | - [tag (in-list (rendered-post-tags info))]) |
189 | | - (hash-update tagged-deps+infos tag (λ~>> (cons (list dep info))) '()))) |
190 | | - |
191 | | - (for ([(tag deps+infos) (in-immutable-hash tagged-deps+infos)]) |
192 | | - (define total-pages (ceiling (/ (length deps+infos) num-posts-per-page))) |
193 | | - (for ([deps+infos (in-slice num-posts-per-page deps+infos)] |
| 167 | + (build-post-index total-pages number posts)) |
| 168 | + |
| 169 | + (define tagged-posts |
| 170 | + (for*/fold ([tagged-deps+infos (hash)]) |
| 171 | + ([post (in-list post-infos)] |
| 172 | + [tag (in-list (rendered-post-tags post))]) |
| 173 | + (hash-update tagged-deps+infos tag (λ~>> (cons post)) '()))) |
| 174 | + |
| 175 | + (for ([(tag posts) (in-immutable-hash tagged-posts)]) |
| 176 | + (define total-pages (ceiling (/ (length posts) num-posts-per-page))) |
| 177 | + (for ([posts (in-slice num-posts-per-page posts)] |
194 | 178 | [page-number (in-naturals 1)]) |
195 | | - (build-tag-index total-pages page-number tag deps+infos)))) |
| 179 | + (build-tag-index total-pages page-number tag posts)))) |
196 | 180 |
|
197 | 181 | (parameterize ([current-directory "/home/alexis/code/blog2"]) |
198 | 182 | (build-all)) |
0 commit comments