Skip to content

Commit 739b7c3

Browse files
committed
Step 2
1 parent 2ebcf54 commit 739b7c3

File tree

4 files changed

+60
-42
lines changed

4 files changed

+60
-42
lines changed

src/components/HelloWorld.vue

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/components/QuestionList.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<div class="ui container">
3+
<div class="ui comments" v-for="question in questions" :key="question.question_id">
4+
<question-list-item :question="question" />
5+
</div>
6+
</div>
7+
</template>
8+
9+
<script>
10+
import questions from '../api/stackoverflow-search-multiple.json'
11+
import QuestionListItem from './QuestionListItem'
12+
13+
export default {
14+
name: 'QuestionList',
15+
components: {
16+
QuestionListItem
17+
},
18+
data () {
19+
return {
20+
questions: questions.items
21+
}
22+
}
23+
}
24+
</script>

src/components/QuestionListItem.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<div class="comment">
3+
<a class="avatar">
4+
<img :src="question.owner.profile_image">
5+
</a>
6+
<div class="content">
7+
<a class="author">{{ question.owner.display_name }}</a>
8+
<div class="metadata">
9+
<div>{{ new Date(question.creation_date*1000).toLocaleDateString() }}</div>
10+
<div><i class="star icon"></i>{{ question.score }} Votes</div>
11+
<div><i class="comment icon"></i>{{ question.answer_count }} answers</div>
12+
</div>
13+
<div v-for="tag in question.tags" :key="tag" class="ui mini label">{{ tag }}</div>
14+
<div class="text">
15+
{{ question.title }}
16+
</div>
17+
<div v-if="question.is_answered" class="actions">
18+
<a :href="question.link">View answers</a>
19+
</div>
20+
</div>
21+
</div>
22+
</template>
23+
24+
<script>
25+
export default {
26+
name: 'QuestionListItem',
27+
props: {
28+
question: {
29+
type: Object
30+
}
31+
}
32+
}
33+
</script>

src/router/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import Vue from 'vue'
22
import Router from 'vue-router'
3-
import HelloWorld from '@/components/HelloWorld'
3+
import QuestionList from '@/components/QuestionList'
44

55
Vue.use(Router)
66

77
export default new Router({
88
routes: [
99
{
1010
path: '/',
11-
name: 'HelloWorld',
12-
component: HelloWorld
11+
name: 'QuestionList',
12+
component: QuestionList
1313
}
1414
]
1515
})

0 commit comments

Comments
 (0)