-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.ts
61 lines (57 loc) · 1.48 KB
/
example.ts
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
50
51
52
53
54
55
56
57
58
59
60
61
import { default as Nattramn } from './index.ts';
const template = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<nattramn-router></nattramn-router>
<script type="module" src="nattramn-client.js"></script>
</body>
</html>
`;
const config = {
server: {
serveStatic: `${Deno.cwd()}/public`
},
router: {
pages: [
{
route: '/',
template,
handler: async () => ({
body: `
<h1>Nattramn</h1>
<h2>Home</h2>
<p>
Click link to go further!<br>
<img src="demo.png"><br>
<img src="demo.png"><br>
<img src="demo.png"><br>
Read <nattramn-link href="/about">about me.</nattramn-link>
</p>
`,
head: '<title>Home - Nattramn</title>'
})
},
{
route: '/about',
template,
handler: async () => ({
body: `
<h1>Nattramn</h1>
<h2>About</h2>
<p>The Nattramn only occationally shows himself[1] and is said to be ghost of a suicide[2].</p>
<small>1) This library sends partial content on some requests.</small>
<small>2) Node.js 🤡.</small>
`,
head: '<title>About - Nattramn</title>'
})
}
]
}
};
const nattramn = new Nattramn(config);
await nattramn.startServer(5000);