File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 9
9
</li >
10
10
</ul >
11
11
</async-content >
12
+ <slot name =" button" >
13
+ <button type =" button" @click =" loader.loadPage()" class =" all-posts-more-button" > Load More Posts</button >
14
+ </slot >
12
15
</div >
13
16
</div >
14
17
</template >
Original file line number Diff line number Diff line change 9
9
<div class =" col-sm" >
10
10
<h4 >post-summary</h4 >
11
11
<!-- 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-->
13
13
<async-content :loaded =" postLoader.pages[0].loaded" >
14
14
<div v-for =" (post,index) of postLoader.pages[0].content" :key =" index" >
15
15
<post-summary :post =" post" class =" post-summary" ></post-summary >
20
20
<div class =" col-sm" >
21
21
<h4 >single-post</h4 >
22
22
<!-- 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 -->
24
24
<div v-for =" (page,index) of singlePostLoader.pages" :key =" index" >
25
25
<async-content :loaded =" page.loaded" >
26
26
<!-- This post loader only contains one post per page (we set per_page=1 in the post loader query params) -->
31
31
</div >
32
32
<div class =" col-lg" >
33
33
<h4 >all-posts</h4 >
34
+ <all-posts :loader =" allPostLoader" ></all-posts >
34
35
</div >
35
36
</div >
36
37
@@ -64,13 +65,26 @@ export default {
64
65
}),
65
66
singlePostLoader: this .createWpLoader (' https://pixelthin.com/content/wp-json/wp/v2/posts' , {
66
67
queryParams: [' per_page=1' ]
68
+ }),
69
+ allPostLoader: this .createWpLoader (' https://pixelthin.com/content/wp-json/wp/v2/posts' , {
70
+ queryParams: [' per_page=3' ]
67
71
})
68
72
}
69
73
}
70
74
}
71
75
</script >
72
76
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
+
74
88
p {
75
89
text-align : left ;
76
90
margin-left : 10% ;
You can’t perform that action at this time.
0 commit comments