;; content-on-sx — full HTML page wrapper.
;;
;; content/page composes the metadata + render layers into the shippable
;; artifact the blog serves: a minimal valid HTML5 document with an escaped
;; <title> (from doc metadata, falling back to the id) and the rendered blocks
;; as the body.
;;
;; Requires (loaded by harness): doc.sx, render.sx (asHTML + htmlEscaped),
;; meta.sx (doc-title).

(define ct-html-escape (fn (s) (str (st-send s "htmlEscaped" (list)))))

(define
  content/page-title
  (fn (doc) (let ((t (doc-title doc))) (if (= t nil) (doc-id doc) t))))

(define
  content/page
  (fn
    (doc)
    (str
      "<!doctype html><html><head><meta charset=\"utf-8\"><title>"
      (ct-html-escape (content/page-title doc))
      "</title></head><body>"
      (asHTML doc)
      "</body></html>")))
