/
UserView.vue
61 lines (54 loc) · 1.31 KB
/
UserView.vue
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
<template>
<div class="user-view" v-show="user">
<ul>
<li><span class="label">user:</span> {{user.id}}</li>
<li><span class="label">created:</span> {{user.created | fromNow}} ago</li>
<li><span class="label">karma:</span> {{user.karma}}</li>
<li>
<span class="label">about:</span>
<div class="about">
{{{user.about}}}
</div>
</li>
</ul>
<p class="links">
<a :href="'https://news.ycombinator.com/submitted?id=' + user.id">submissions</a><br>
<a :href="'https://news.ycombinator.com/threads?id=' + user.id">comments</a>
</p>
</div>
</template>
<script>
import store from '../store'
export default {
name: 'UserView',
data () {
return {
user: {}
}
},
route: {
data ({ to }) {
// Promise sugar syntax: return an object that contains Promise fields.
// http://router.vuejs.org/en/pipeline/data.html#promise-sugar
document.title = 'Profile: ' + to.params.id + ' | Vue.js HN Clone'
return {
user: store.fetchUser(to.params.id)
}
}
}
}
</script>
<style lang="stylus">
@import "../variables.styl"
.user-view
color $gray
li
margin 5px 0
.label
display inline-block
min-width 60px
.about
margin-top 1em
.links a
text-decoration underline
</style>