;; Extension — SEO-complete HTML page (lang + meta description).

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

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

(content-test
  "page-full"
  (content/page-full d)
  "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>My Title</title><meta name=\"description\" content=\"Hi Hello world\"></head><body><h1>Hi</h1><p>Hello world</p></body></html>")

;; description escaped
(content-test
  "page-full escapes description"
  (content/page-full
    (doc-with-title
      (doc-append (doc-empty "x") (mk-text "p" "a < b & c"))
      "T"))
  "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>T</title><meta name=\"description\" content=\"a &lt; b &amp; c\"></head><body><p>a &lt; b &amp; c</p></body></html>")

;; title falls back to id, empty description for empty doc
(content-test
  "page-full empty"
  (content/page-full (doc-empty "fallback"))
  "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>fallback</title><meta name=\"description\" content=\"\"></head><body></body></html>")

;; body reflects edits
(content-test
  "page-full reflects edits"
  (content/page-full (doc-update d "p" "text" "Bye now"))
  "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>My Title</title><meta name=\"description\" content=\"Hi Bye now\"></head><body><h1>Hi</h1><p>Bye now</p></body></html>")
