entry-server.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // @refresh reload
  2. import { createHandler, StartServer } from "@solidjs/start/server"
  3. import { getRequestEvent } from "solid-js/web"
  4. import { dir, localeFromRequest, tag } from "~/lib/language"
  5. const criticalCSS = `[data-component="top"]{min-height:80px;display:flex;align-items:center}`
  6. export default createHandler(
  7. () => (
  8. <StartServer
  9. document={({ assets, children, scripts }) => {
  10. const evt = getRequestEvent()
  11. const locale = evt ? localeFromRequest(evt.request) : "en"
  12. return (
  13. <html lang={tag(locale)} dir={dir(locale)} data-locale={locale}>
  14. <head>
  15. <meta charset="utf-8" />
  16. <meta name="viewport" content="width=device-width, initial-scale=1" />
  17. <meta property="og:image" content="/social-share.png" />
  18. <meta property="twitter:image" content="/social-share.png" />
  19. <style>{criticalCSS}</style>
  20. {assets}
  21. </head>
  22. <body>
  23. <div id="app">{children}</div>
  24. {scripts}
  25. </body>
  26. </html>
  27. )
  28. }}
  29. />
  30. ),
  31. {
  32. mode: "async",
  33. },
  34. )