Skip to content

Commit

Permalink
#1 feat(article): Added article page and links to post
Browse files Browse the repository at this point in the history
  • Loading branch information
mochenski committed Jul 15, 2020
1 parent 7ce89d1 commit d48e567
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 3 deletions.
15 changes: 12 additions & 3 deletions front-end/components/ArticlePost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
<v-list-item-avatar color="grey">
<img src="https://randomuser.me/api/portraits/men/81.jpg" />
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title class="headline">{{ articleTitle }}</v-list-item-title>
<v-list-item-content class="color">
<nuxt-link :to="'/articles/'+articleSlug">
<v-list-item-title class="headline">{{ articleTitle }}</v-list-item-title>
</nuxt-link>
<v-list-item-subtitle>by {{ articleAuthor }}</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
Expand All @@ -23,10 +25,17 @@
<script>
export default {
props: {
articleSlug: String,
articleAuthor: String,
articleTitle: String,
articleBody: String,
articleTags: Array
}
}
</script>
</script>

<style>
.color a {
color: black;
}
</style>
38 changes: 38 additions & 0 deletions front-end/layouts/article.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<template>
<v-app>
<v-app-bar class="cyan accent-3 color" flat app>
<nuxt-link to="/">
<v-toolbar-title class="text-uppercase">Artic</v-toolbar-title>
</nuxt-link>

<v-spacer></v-spacer>

<div v-if="$auth.loggedIn">
<v-btn @click="$auth.logout()">Logout</v-btn>
<nuxt-link to="/dashboard">
<v-btn>Dashboard</v-btn>
</nuxt-link>
</div>
<nuxt-link to="/login" v-else>
<v-btn>Login</v-btn>
</nuxt-link>
</v-app-bar>
<v-main>
<v-content>
<nuxt />
</v-content>
</v-main>
</v-app>
</template>

<script>
export default {
data: () => ({})
}
</script>

<style>
.color a {
color: black;
}
</style>
59 changes: 59 additions & 0 deletions front-end/pages/articles/_slug.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<v-container>
<v-row>
<article-post
:articleTitle="article.title"
:articleSlug="article.slug"
:articleAuthor="article.author.name"
:articleBody="article.body"
:articleTags="article.tags"
/>
</v-row>
</v-container>
</template>

<script>
import ArticlePost from '@/components/ArticlePost'
export default {
layout: 'article',
components: {
ArticlePost
},
mounted() {
this.loadArticle()
},
data: () => ({
loading: false,
article: {
author: {} // defined author because :artucleAuthor won't accept undefined
},
tags: []
}),
computed: {
params() {
return this.$route.params
}
},
methods: {
async loadArticle() {
this.loading = true
await this.$axios
.get(`articles/${this.params.slug}`)
.then((response) => {
console.log(response.data)
this.article = response.data
this.loading = false
})
.catch((err) => {
console.log(err.response)
this.loading = false
})
}
}
}
</script>
3 changes: 3 additions & 0 deletions front-end/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
v-for="article in newArticles"
:key="article.id"
:articleTitle="article.title"
:articleSlug="article.slug"
:articleAuthor="article.author.name"
:articleBody="article.body"
:articleTags="article.tags"
Expand All @@ -16,6 +17,7 @@
v-for="article in hotArticles"
:key="article.id"
:articleTitle="article.title"
:articleSlug="article.slug"
:articleAuthor="article.author.name"
:articleBody="article.body"
:articleTags="article.tags"
Expand All @@ -26,6 +28,7 @@
v-for="article in allArticles"
:key="article.id"
:articleTitle="article.title"
:articleSlug="article.slug"
:articleAuthor="article.author.name"
:articleBody="article.body"
:articleTags="article.tags"
Expand Down

0 comments on commit d48e567

Please sign in to comment.