◊(Local Yarn Code "Artifact [1dda01dc]")

Artifact 1dda01dcc1b67b9f21bd3e90f4d6e2c6f69dd24f04a3225d8e5255705f6e3080:

#lang pollen/mode racket/base

; SPDX-License-Identifier: BlueOak-1.0.0
; This file is licensed under the Blue Oak Model License 1.0.0.

;; Builds the paginated “blog” HTML files (blog-pg1.html ...) from the SQLite cache
;; The files will be written out every time this module is evaluated! (see end)

(require "crystalize.rkt"

(provide main)

;; How many items per blog page
(define per-page 5)

;; Returns a string containing the entire HTML contents of a given blog page
(define (blog-page posts-str pagenum total-pages)
  (define page-nav (html$-paginate-navlinks pagenum total-pages "blog"))
 <!DOCTYPE html>
 <html lang="en">
 ◊html$-page-head[(format "The Local Yarn: Blog, p. ~a" pagenum)]

 <aside><i>Everything, in reverse time order. Well, almost everything.</i></aside>

 <nav id="top-nav"><ul>◊|page-nav|</ul></nav>


 <nav id="bottom-nav"><ul>◊|page-nav|</ul></nav>


;; Grabs all the articles+notes from the cache and writes out all the blog page files
(define (build-blog)
  (define arts-n-notes (slice-at (listing-htmls (articles+notes 'full #:series #f)) per-page))
  (define pagecount (length arts-n-notes))
  (for ([pagenum (in-range 1 (+ 1 pagecount))]
        [page    (in-list arts-n-notes)])
    (define filename (format "blog-pg~a.html" pagenum))
    (displayln (format "Writing: ~a" filename))
    (display-to-file (blog-page (apply string-append page) pagenum pagecount)
                     #:mode 'text
                     #:exists 'replace)))

(define (main)
  ;; Do it!