2018-07-12 17:21:42 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// P A C K A G E
|
|
|
|
|
2018-07-13 23:58:24 +02:00
|
|
|
const html = require("choo-async/html");
|
2018-07-12 17:21:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 23:58:24 +02:00
|
|
|
// E X P O R T
|
2018-07-12 17:21:42 +02:00
|
|
|
|
2018-07-13 23:58:24 +02:00
|
|
|
module.exports = exports = (head, body) => {
|
2018-07-12 17:21:42 +02:00
|
|
|
return (state, emit) => {
|
|
|
|
const bodyPromise = Promise.resolve(body(state, emit));
|
|
|
|
const headPromise = bodyPromise.then(() => head(state, emit)); // resolve `head` once `body` is resolved
|
|
|
|
|
2018-07-13 23:58:24 +02:00
|
|
|
return html`
|
2018-07-12 17:21:42 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
${headPromise}
|
|
|
|
${bodyPromise}
|
|
|
|
</html>
|
|
|
|
`;
|
|
|
|
};
|
2018-07-13 23:58:24 +02:00
|
|
|
};
|