Skip to content

Commit

Permalink
#1 feat(sections): Showing hot, new and all articles
Browse files Browse the repository at this point in the history
  • Loading branch information
mochenski committed Jul 15, 2020
1 parent abf599b commit 108725f
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions front-end/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,34 @@
<v-container>
<v-tabs-items v-model="tabs">
<v-tab-item id="new">
<article-post></article-post>
<article-post
v-for="article in newArticles"
:key="article.id"
:articleTitle="article.title"
:articleAuthor="article.author.name"
:articleBody="article.body"
:articleTags="article.tags"
/>
</v-tab-item>
<v-tab-item id="hot">
<article-post></article-post>
<article-post
v-for="article in hotArticles"
:key="article.id"
:articleTitle="article.title"
:articleAuthor="article.author.name"
:articleBody="article.body"
:articleTags="article.tags"
/>
</v-tab-item>
<v-tab-item id="all">
<article-post
v-for="article in articles"
v-for="article in allArticles"
:key="article.id"
:articleTitle="article.title"
:articleAuthor="article.author.name"
:articleBody="article.body"
:articleTags="article.tags"
></article-post>
/>
</v-tab-item>
</v-tabs-items>
</v-container>
Expand All @@ -27,26 +41,52 @@ import ArticlePost from '@/components/ArticlePost'
export default {
mounted() {
this.loadNew()
this.loadHot()
this.loadAll()
},
layout: 'articles',
components: {
ArticlePost
},
data: () => ({
articles: Object
newArticles: Object,
hotArticles: Object,
allArticles: Object
}),
computed: {
tabs() {
return this.$store.state.tabs.tab
}
},
methods: {
async loadAll() {
this.$axios
.get('/articles/all')
.then((response) => {
this.allArticles = response.data
})
.catch((err) => {
console.log(err.response)
})
},
async loadHot() {
this.$axios
.get('/articles')
.get('/articles/hot')
.then((response) => {
this.hotArticles = response.data
})
.catch((err) => {
console.log(err.response)
})
},
async loadNew() {
this.$axios
.get('/articles/new')
.then((response) => {
this.articles = response.data
this.newArticles = response.data
})
.catch((err) => {
console.log(err.response)
Expand Down

0 comments on commit 108725f

Please sign in to comment.