-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
59 lines (56 loc) · 1.84 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- Hosted vue libraries-->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="app"></div>
<script type="text/x-template" id="page-contents">
<div class="container">
<component v-for="(widget, index) in definitions.widgets" :key="index" v-if="canHandle(widget.type)" v-bind:is="widget.type" v-bind:title="widget.title" v-bind:config="widget.data"></component>
</div>
</script>
<script type="module">
import definitions from './definition.js'
import Banner from './widgets/banner.js'
import ArticleList from './widgets/article_list.js'
import ItemList from './widgets/item_list.js'
import LocalRecent from './widgets/local_recent.js'
import ShopList from './widgets/shop_list.js'
var app = new Vue({
el: '#app',
template: '#page-contents',
components: {
'banner': Banner,
'article_list': ArticleList,
'item_list': ItemList,
'local_recent_items': LocalRecent,
'shop_list': ShopList
},
data: function() {
return {
definitions
}
},
computed: {
widgets: () => {
return this.definitions.widgets
}
},
methods: {
canHandle: function (widgetType) {
const registered = this.$options.components[widgetType] !== undefined
if (!registered) {
console.log(`cannot handle ${widgetType}, skipping..`)
}
return registered
}
}
})
</script>
</body>
</html>