body.js 906 B

1234567891011121314151617181920212223242526272829303132333435
  1. const html = require('choo/html');
  2. const Promo = require('./promo');
  3. const Header = require('./header');
  4. const Footer = require('./footer');
  5. function banner(state) {
  6. if (state.layout) {
  7. return; // server side
  8. }
  9. const show =
  10. !state.capabilities.standalone &&
  11. !state.route.startsWith('/unsupported/') &&
  12. state.locale === 'en-US';
  13. if (show) {
  14. return state.cache(Promo, 'promo').render();
  15. }
  16. }
  17. module.exports = function body(main) {
  18. return function(state, emit) {
  19. const b = html`
  20. <body
  21. class="flex flex-col items-center font-sans md:h-screen md:bg-grey-10 dark:bg-black"
  22. >
  23. ${banner(state, emit)} ${state.cache(Header, 'header').render()}
  24. ${main(state, emit)} ${state.cache(Footer, 'footer').render()}
  25. </body>
  26. `;
  27. if (state.layout) {
  28. // server side only
  29. return state.layout(state, b);
  30. }
  31. return b;
  32. };
  33. };