forked from Glatek/nattramn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.ts
59 lines (55 loc) · 1.16 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
import Appetit 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>
<appetit-router></appetit-router>
<script type="module" src="appetit-client.js"></script>
</body>
</html>
`;
const config = {
server: {
serveStatic: `./public`,
},
router: {
pages: [
{
route: "/",
template,
handler: async () => ({
body: `
<h1>Appetit</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 <appetit-link href="/about">about me.</appetit-link>
</p>
`,
head: "<title>Home - Appetit</title>",
}),
},
{
route: "/about",
template,
handler: async () => ({
body: `
<h1>Appetit</h1>
<h2>About</h2>
<p>Bun appetit 😘👌</p>
`,
head: "<title>About - Appetit</title>",
}),
},
],
},
};
const appetit = new Appetit(config);
appetit.serve(5000);