moineau/generate.js

49 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-09-23 10:14:52 +02:00
var marked = require('marked')
var fs = require('fs')
const inFile = "README.md"
const outFile = "dist/index.html"
function parse(inFile, outFile) {
const inputContent = fs.readFileSync(inFile, 'utf8')
const content = `<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2024-09-23 10:18:13 +02:00
<title>moineau.css</title>
<link href="css/moineau.min.css" rel="stylesheet">
2024-09-23 10:14:52 +02:00
<link
rel="icon"
2024-09-23 10:18:13 +02:00
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🐦</text></svg>"
2024-09-23 10:14:52 +02:00
/>
</head>
<body>
<header>
<nav>
<ul>
2024-09-29 16:11:55 +02:00
<li><a href="/">🏠 Accueil</a></li>
<li><a href="/exemples.html">🗒 Exemples</a></li>
2024-09-23 10:18:13 +02:00
<li><a href="https://git.kobold.cafe/kazhnuz/moineau">Sources</a></li>
2024-09-23 10:14:52 +02:00
</ul>
</nav>
</header>
<main>
<article>
${marked.parse(inputContent)}
</article>
</main>
<hr>
<footer class="flex">
2024-09-23 10:18:13 +02:00
<div><small>moineau</small></div>
2024-09-23 10:14:52 +02:00
<div><small>CC BY <a href="https://kazhnuz.space/">Kazhnuz</a></small></div>
</footer>
</body>
</html>`
fs.writeFileSync(outFile, content)
}
parse("README.md", "dist/index.html")
parse("exemples/exemples.md", "dist/exemples.html")