#8 render title

This commit is contained in:
Seth Trowbridge 2023-04-06 23:44:27 -04:00
parent 91a2fe76c5
commit 767e681640
2 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,6 @@
"install": "deno install -f -A --unstable --no-lock -n eno server.tsx", "install": "deno install -f -A --unstable --no-lock -n eno server.tsx",
"run": "deno run -A --unstable --no-lock server.tsx", "run": "deno run -A --unstable --no-lock server.tsx",
"host": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts", "host": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts",
"complete": "deno task host & cd example && pwd && deno task dev" "example": "cd example && pwd && deno task dev"
} }
} }

View File

@ -4,6 +4,7 @@ import { debounce } from "https://deno.land/std@0.151.0/async/debounce.ts";
import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2"; import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2";
import * as Twind from "https://esm.sh/@twind/core@1.1.3"; import * as Twind from "https://esm.sh/@twind/core@1.1.3";
import React, {JSX, createElement as h} from "react"; import React, {JSX, createElement as h} from "react";
import * as Iso from "@eno/iso";
const Transpiled = new Map(); const Transpiled = new Map();
const Transpileable =(inFilePath:string):boolean=> const Transpileable =(inFilePath:string):boolean=>
@ -233,9 +234,11 @@ FileListen("${url.pathname}", reloadHandler);`;
type = `text/html`; type = `text/html`;
body = `<!doctype html> body = `<!doctype html>
<html> <html lang="en">
<head> <head>
<title>${Iso.Meta.title}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8"/>
<style data-twind>${results.css}</style> <style data-twind>${results.css}</style>
<script type="importmap">${JSON.stringify(ImportObject)}</script> <script type="importmap">${JSON.stringify(ImportObject)}</script>
<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.1/dist/es-module-shims.js" crossorigin="anonymous"></script> <script async src="https://ga.jspm.io/npm:es-module-shims@1.5.1/dist/es-module-shims.js" crossorigin="anonymous"></script>
@ -253,7 +256,7 @@ FileListen("${url.pathname}", reloadHandler);`;
</html>`; </html>`;
} }
return new Response(body, {headers:{"content-type":type as string, "Access-Control-Allow-Origin":"*"}}); return new Response(body, {headers:{"content-type":type as string, "Access-Control-Allow-Origin":"*", charset:"utf-8"}});
} }
catch(error) catch(error)
{ {