Skip to content

Commit df5b912

Browse files
committed
Finishes adding the all-posts component. Final commit before pull request
1 parent 9d32ae5 commit df5b912

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/components/all-posts.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
</li>
1010
</ul>
1111
</async-content>
12+
<slot name="button">
13+
<button type="button" @click="loader.loadPage()" class="all-posts-more-button"> Load More Posts</button>
14+
</slot>
1215
</div>
1316
</div>
1417
</template>

src/example/example.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="col-sm">
1010
<h4>post-summary</h4>
1111
<!-- In this example, we're just loading one page of results from the WP-REST API.
12-
For an example of loading more than one post, see the single-post section-->
12+
For an example of loading more than one post, see the single-post section-->
1313
<async-content :loaded="postLoader.pages[0].loaded">
1414
<div v-for="(post,index) of postLoader.pages[0].content" :key="index">
1515
<post-summary :post="post" class="post-summary"></post-summary>
@@ -20,7 +20,7 @@
2020
<div class="col-sm">
2121
<h4>single-post</h4>
2222
<!-- In this example we're loading one post at a time and letting the user pull a new on in dynamically
23-
whenever they click a button -->
23+
whenever they click a button -->
2424
<div v-for="(page,index) of singlePostLoader.pages" :key="index">
2525
<async-content :loaded="page.loaded">
2626
<!-- This post loader only contains one post per page (we set per_page=1 in the post loader query params) -->
@@ -31,6 +31,7 @@
3131
</div>
3232
<div class="col-lg">
3333
<h4>all-posts</h4>
34+
<all-posts :loader="allPostLoader"></all-posts>
3435
</div>
3536
</div>
3637

@@ -64,13 +65,26 @@ export default {
6465
}),
6566
singlePostLoader: this.createWpLoader('https://pixelthin.com/content/wp-json/wp/v2/posts', {
6667
queryParams: ['per_page=1']
68+
}),
69+
allPostLoader: this.createWpLoader('https://pixelthin.com/content/wp-json/wp/v2/posts', {
70+
queryParams: ['per_page=3']
6771
})
6872
}
6973
}
7074
}
7175
</script>
7276

73-
<style scoped>
77+
<style>
78+
.all-posts-ul {
79+
list-style: none;
80+
}
81+
82+
.all-posts-li {
83+
margin: 10px;
84+
background-color: lightgray;
85+
overflow: hidden;
86+
}
87+
7488
p {
7589
text-align: left;
7690
margin-left: 10%;

0 commit comments

Comments
 (0)