-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.mjs
49 lines (35 loc) · 983 Bytes
/
example.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import {md, html} from './lib.mjs';
import {writeFile} from 'fs';
const template = ({title, tags, content}) => html`
<h1>${title}</h1>
<ul style="text-align: right;">
${
tags.map(tag =>
html`<li style="display: inline;"><code>${tag}</code> - </li>`
)
}
</ul>
${content}
${md`Markdown inside of the \`html\` template because **why not**`}
`;
const blog = md`
This is a blog.
Text, text, text, ...
\`\`\`js
const a = 56;
\`\`\`
End of blog
`
const index_html = html`
<head>
<meta charset="utf-8"/>
<title>Example</title>
</head>
<body>
<${template} title="My Blog" tags=${["blog", "programming"]}content=${blog} />
</body>
`;
// https://ourcodeworld.com/articles/read/1186/how-to-write-a-file-in-node-js-using-the-utf-8-encoding-with-bom
writeFile('index.html', "\ufeff" + index_html, err => {
if (err) console.error(err);
});