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
+37 -32
View File
@@ -137,35 +137,29 @@ CMD ["run", "-A", "main.ts"]
);
}
const ROUTES_INDEX_TSX = `import { Head } from "$fresh/runtime.ts";
import { useSignal } from "@preact/signals";
const ROUTES_INDEX_TSX = `import { useSignal } from "@preact/signals";
import Counter from "../islands/Counter.tsx";
export default function Home() {
const count = useSignal(3);
return (
<>
<Head>
<title>${basename(resolvedDirectory)}</title>
</Head>
<div class="px-4 py-8 mx-auto bg-[#86efac]">
<div class="max-w-screen-md mx-auto flex flex-col items-center justify-center">
<img
class="my-6"
src="/logo.svg"
width="128"
height="128"
alt="the Fresh logo: a sliced lemon dripping with juice"
/>
<h1 class="text-4xl font-bold">Welcome to Fresh</h1>
<p class="my-4">
Try updating this message in the
<code class="mx-2">./routes/index.tsx</code> file, and refresh.
</p>
<Counter count={count} />
</div>
<div class="px-4 py-8 mx-auto bg-[#86efac]">
<div class="max-w-screen-md mx-auto flex flex-col items-center justify-center">
<img
class="my-6"
src="/logo.svg"
width="128"
height="128"
alt="the Fresh logo: a sliced lemon dripping with juice"
/>
<h1 class="text-4xl font-bold">Welcome to Fresh</h1>
<p class="my-4">
Try updating this message in the
<code class="mx-2">./routes/index.tsx</code> file, and refresh.
</p>
<Counter count={count} />
</div>
</>
</div>
);
}
`;
@@ -436,23 +430,34 @@ const APP_WRAPPER = useTwind
export default function App({ Component }: AppProps) {
return (
<>
<Component />
</>
<html>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>${basename(resolvedDirectory)}</title>
</head>
<body>
<Component />
</body>
</html>
);
}
`
: `import { AppProps } from "$fresh/server.ts";
import { Head } from "$fresh/runtime.ts";
export default function App({ Component }: AppProps) {
return (
<>
<Head>
<html>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>${basename(resolvedDirectory)}</title>
<link rel="stylesheet" href="/styles.css" />
</Head>
<Component />
</>
</head>
<body>
<Component />
</body>
</html>
);
}
`;