feat: Support setting <html> in _app template (#1617)

This commit is contained in:
Marvin Hagemeister
2023-08-11 18:40:20 +02:00
committed by GitHub
parent d601f4cef4
commit 86f92114d8
27 changed files with 414 additions and 95 deletions
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts";
await dev(import.meta.url, "./main.ts");
+21
View File
@@ -0,0 +1,21 @@
// DO NOT EDIT. This file is generated by Fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
import * as $0 from "./routes/_app.tsx";
import * as $1 from "./routes/head.tsx";
import * as $2 from "./routes/index.tsx";
import * as $3 from "./routes/title.tsx";
const manifest = {
routes: {
"./routes/_app.tsx": $0,
"./routes/head.tsx": $1,
"./routes/index.tsx": $2,
"./routes/title.tsx": $3,
},
islands: {},
baseUrl: import.meta.url,
};
export default manifest;
+10
View File
@@ -0,0 +1,10 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
@@ -0,0 +1,25 @@
import { AppProps, Handler } from "$fresh/server.ts";
export const handler: Handler = (_req, ctx) => {
ctx.state.lang = "de";
return ctx.render();
};
export default function App(
{ Component, state }: AppProps<unknown, { lang: string }>,
) {
return (
<html lang={state.lang}>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>fresh title</title>
</head>
<body>
<div class="inner-body">
<Component />
</div>
</body>
</html>
);
}
@@ -0,0 +1,12 @@
import { Head } from "$fresh/runtime.ts";
export default function Home() {
return (
<div class="page">
<Head>
<meta name="fresh" content="test" />
</Head>
/head
</div>
);
}
@@ -0,0 +1,7 @@
export default function Home() {
return (
<div class="page">
Home
</div>
);
}
@@ -0,0 +1,12 @@
import { Head } from "$fresh/runtime.ts";
export default function Home() {
return (
<div class="page">
<Head>
<title>foo bar</title>
</Head>
/title
</div>
);
}