45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
export function writeStaticHtmlTemplate(targetDir, name) {
|
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
fs.writeFileSync(path.join(targetDir, 'index.html'), `<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>${name}</title>
|
|
<link rel="stylesheet" href="style.css" />
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<h1>${name}</h1>
|
|
<p>Edit <code>index.html</code>, <code>style.css</code>, and <code>script.js</code> to get started.</p>
|
|
</main>
|
|
<script src="script.js"></script>
|
|
</body>
|
|
</html>
|
|
`);
|
|
fs.writeFileSync(path.join(targetDir, 'style.css'), `:root {
|
|
color-scheme: light dark;
|
|
font-family: system-ui, sans-serif;
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
display: grid;
|
|
place-items: center;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
main {
|
|
max-width: 40rem;
|
|
padding: 2rem;
|
|
text-align: center;
|
|
}
|
|
`);
|
|
fs.writeFileSync(path.join(targetDir, 'script.js'), `// Entry point for ${name}.
|
|
console.log('${name} loaded');
|
|
`);
|
|
return targetDir;
|
|
}
|
|
//# sourceMappingURL=staticHtml.js.map
|