;; Extension — full HTML page wrapper.

(st-bootstrap-classes!)
(content/bootstrap!)

(define
  d
  (doc-with-title
    (doc-append (doc-empty "post") (mk-heading "h" 1 "Hi"))
    "My Title"))

(content-test
  "page"
  (content/page d)
  "<!doctype html><html><head><meta charset=\"utf-8\"><title>My Title</title></head><body><h1>Hi</h1></body></html>")

(content-test
  "page title escaped"
  (content/page (doc-with-title (doc-empty "x") "A < B"))
  "<!doctype html><html><head><meta charset=\"utf-8\"><title>A &lt; B</title></head><body></body></html>")

(content-test
  "page falls back to id"
  (content/page (doc-empty "fallback"))
  "<!doctype html><html><head><meta charset=\"utf-8\"><title>fallback</title></head><body></body></html>")

(content-test "page-title from meta" (content/page-title d) "My Title")
(content-test
  "page-title fallback id"
  (content/page-title (doc-empty "z"))
  "z")

(content-test
  "page body reflects edits"
  (content/page (doc-update d "h" "text" "Bye"))
  "<!doctype html><html><head><meta charset=\"utf-8\"><title>My Title</title></head><body><h1>Bye</h1></body></html>")

(content-test
  "page multi-block body"
  (content/page
    (doc-append (doc-with-title (doc-empty "p") "T") (mk-text "x" "para")))
  "<!doctype html><html><head><meta charset=\"utf-8\"><title>T</title></head><body><p>para</p></body></html>")
