Skip to content

Commit 29bf174

Browse files
author
Shaun Pelling
committed
added lesson 44 code
1 parent 8c581e0 commit 29bf174

File tree

6 files changed

+49
-56
lines changed

6 files changed

+49
-56
lines changed

src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<script>
99
// Imports
1010
import showBlogs from './components/showBlogs.vue';
11-
import listBlogs from './components/listBlogs.vue';
1211
import header from './components/header.vue';
1312
1413
export default {

src/components/addBlog.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,21 @@ export default {
6363
}
6464
#add-blog{
6565
margin: 20px auto;
66-
max-width: 500px;
66+
max-width: 600px;
67+
padding: 20px;
6768
}
6869
label{
6970
display: block;
7071
margin: 20px 0 10px;
7172
}
72-
input[type="text"], textarea{
73+
input[type="text"], textarea, select{
7374
display: block;
7475
width: 100%;
7576
padding: 8px;
7677
}
78+
textarea{
79+
height:200px;
80+
}
7781
#preview{
7882
padding: 10px 20px;
7983
border: 1px dotted #ccc;
@@ -90,4 +94,18 @@ h3{
9094
display: inline-block;
9195
margin-top: 0;
9296
}
97+
hr{
98+
display: none;
99+
}
100+
button{
101+
display: block;
102+
margin: 20px 0;
103+
background: crimson;
104+
color: #fff;
105+
border: 0;
106+
padding: 14px;
107+
border-radius: 4px;
108+
font-size: 18px;
109+
cursor: pointer;
110+
}
93111
</style>

src/components/header.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ li{
2424
a{
2525
color: #fff;
2626
text-decoration: none;
27-
padding: 6px 8px;
27+
padding: 12px;
2828
border-radius: 5px;
2929
}
3030
nav{
31-
background: #444;
32-
padding: 20px 0;
31+
background: crimson;
32+
padding: 30px 0;
3333
margin-bottom: 40px;
3434
}
3535
.router-link-active{
36-
background: #eee;
36+
background: rgba(255,255,255,0.8);
3737
color: #444;
3838
}
3939
</style>

src/components/listBlogs.vue

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

src/components/showBlogs.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<input type="text" v-model="search" placeholder="search blogs" />
55
<div v-for="blog in filteredBlogs" class="single-blog">
66
<router-link v-bind:to="'/blog/' + blog.id"><h2>{{ blog.title }}</h2></router-link>
7-
<article>{{ blog.body }}</article>
7+
<article>{{ blog.content }}</article>
88
</div>
99
</div>
1010
</template>
@@ -21,8 +21,16 @@ export default {
2121
}
2222
},
2323
created() {
24-
this.$http.get('http://jsonplaceholder.typicode.com/posts').then(function(data){
25-
this.blogs = data.body.slice(0,10);
24+
this.$http.get('https://nn-vue-playlist.firebaseio.com/posts.json').then(function(data){
25+
return data.json()
26+
}).then(function(data){
27+
var blogsArray = [];
28+
for (let key in data){
29+
data[key].id = key;
30+
blogsArray.push(data[key]);
31+
}
32+
this.blogs = blogsArray;
33+
//console.log(this.blogs);
2634
});
2735
},
2836
mixins: [searchMixin]
@@ -39,6 +47,7 @@ export default {
3947
margin: 20px 0;
4048
box-sizing: border-box;
4149
background: #eee;
50+
border: 1px dotted #aaa;
4251
}
4352
4453
#show-blogs a{

src/components/singleBlog.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<template>
22
<div id="single-blog">
33
<h1>{{ blog.title }}</h1>
4-
<article>{{ blog.body }}</article>
4+
<article>{{ blog.content }}</article>
5+
<p>Author: {{ blog.author }}</p>
6+
<p>Categories:</p>
7+
<ul>
8+
<li v-for="category in blog.categories">{{ category }}</li>
9+
</ul>
510
</div>
611
</div>
712
</template>
@@ -18,9 +23,10 @@ export default {
1823
}
1924
},
2025
created() {
21-
this.$http.get('http://jsonplaceholder.typicode.com/posts/' + this.id).then(function(data){
22-
// console.log(data);
23-
this.blog = data.body;
26+
this.$http.get('https://nn-vue-playlist.firebaseio.com/posts/' + this.id + '.json').then(function(data){
27+
return data.json();
28+
}).then(function(data){
29+
this.blog = data;
2430
});
2531
}
2632
}
@@ -30,5 +36,8 @@ export default {
3036
#single-blog{
3137
max-width: 960px;
3238
margin: 0 auto;
39+
padding: 20px;
40+
background: #eee;
41+
border: 1px dotted #aaa;
3342
}
3443
</style>

0 commit comments

Comments
 (0)