feat: Support setting <html> in _app template (#1617)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
basename,
|
||||
dirname,
|
||||
existsSync,
|
||||
extname,
|
||||
@@ -230,6 +231,34 @@ await start(manifest, { plugins: [twindPlugin(twindConfig)] });\n`;
|
||||
}
|
||||
}
|
||||
|
||||
// Add default _app.tsx if not present
|
||||
const routes = Array.from(Deno.readDirSync(join(srcDirectory, "routes")));
|
||||
if (!routes.find((entry) => entry.isFile && entry.name.startsWith("_app."))) {
|
||||
const APP_TSX = `import { AppProps } from "$fresh/server.ts";
|
||||
|
||||
export default function App({ Component }: AppProps) {
|
||||
return (
|
||||
<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>
|
||||
);
|
||||
}`;
|
||||
await Deno.writeTextFile(
|
||||
join(srcDirectory, "routes", "_app.tsx"),
|
||||
APP_TSX,
|
||||
);
|
||||
}
|
||||
|
||||
console.log(routes);
|
||||
// await Deno.writeTextFile(MAIN_TS_PATH, MAIN_TS);
|
||||
|
||||
const manifest = await collect(srcDirectory);
|
||||
await generate(srcDirectory, manifest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user