-
Notifications
You must be signed in to change notification settings - Fork 107
/
app.riot
58 lines (55 loc) · 1.2 KB
/
app.riot
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
<app>
<router>
<nav>
<a each={ page in state.pages } href="/{ page.id }">
{ page.title }
</a>
</nav>
<route path="/:id?">
<h1>{getPageById(route).title}</h1>
<p>{getPageById(route).body}</p>
</route>
</router>
<script>
const pages = [
{ id: "", title: "Home", body: "Click the link above." },
{ id: "first", title: "First", body: "This is the first page." },
{ id: "second", title: "Second", body: "This is the second page." }
]
export default {
components: {
router: route.Router,
route: route.Route,
},
state: {
pages
},
getPageById(route) {
const {id} = route.params
return pages.find(page => page.id === id) || pages[0]
}
}
</script>
<style>
:host {
display: block;
font-family: sans-serif;
margin: 0;
padding: 1em;
text-align: center;
color: #666;
}
nav {
display: block;
border-bottom: 1px solid #666;
padding: 0 0 1em;
}
nav > a {
display: inline-block;
padding: 0 .8em;
}
nav > a:not(:first-child) {
border-left: 1px solid #eee;
}
</style>
</app>