// A short e-book made from chapters written in Markdown, ready to download.
//
//   quillo run epub.qwe      then open http://localhost:8080/book.epub

use "epub.qwer"

let chapters = [
    { title: "Beans", text: "Good coffee starts with **fresh beans**, roasted no more than a month ago." },
    { title: "Water", text: "Use water just off the boil: about 94 °C.\n\n- Soft water tastes sweeter\n- Hard water dulls the cup" },
    { title: "Time", text: "Four minutes for a French press. Then pour it all, or it goes bitter." },
]

fn make_book() = epub_write("data/coffee.epub",
    { title: "Coffee at Home", author: "Quillo Café", lang: "en", description: "Three short lessons.", cover: "epub_sample.jpg" },
    chapters | map((c) => { title: c.title, html: str(markdown(c.text)) }))

route GET /book.epub {
    make_book()?
    file("data/coffee.epub")
}
route GET /info {
    make_book()?
    epub_info("data/coffee.epub")
}
