Paginated blog
This commit is contained in:
parent
2fc4459fd2
commit
b11fff8633
3 changed files with 27 additions and 4 deletions
13
src/assets/style/_pagination.scss
Normal file
13
src/assets/style/_pagination.scss
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
.pagination {
|
||||||
|
text-align: center;
|
||||||
|
margin: 1rem;
|
||||||
|
|
||||||
|
a {
|
||||||
|
padding: 1rem;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
@import 'base';
|
@import 'base';
|
||||||
@import 'code';
|
@import 'code';
|
||||||
@import 'content-box';
|
@import 'content-box';
|
||||||
@import 'utils';
|
@import 'pagination';
|
||||||
|
@import 'utils';
|
||||||
|
|
|
@ -8,12 +8,19 @@
|
||||||
<PostCard v-for="edge in $page.posts.edges" :key="edge.node.id" :post="edge.node"/>
|
<PostCard v-for="edge in $page.posts.edges" :key="edge.node.id" :post="edge.node"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pagination">
|
||||||
|
<Pager :info="$page.posts.pageInfo"/>
|
||||||
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<page-query>
|
<page-query>
|
||||||
{
|
query ($page: Int) {
|
||||||
posts: allPost {
|
posts: allPost(perPage: 10, page: $page) @paginate {
|
||||||
|
pageInfo {
|
||||||
|
totalPages
|
||||||
|
currentPage
|
||||||
|
}
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
id
|
id
|
||||||
|
@ -42,11 +49,13 @@
|
||||||
<script>
|
<script>
|
||||||
import Author from '~/components/Author.vue'
|
import Author from '~/components/Author.vue'
|
||||||
import PostCard from '~/components/PostCard.vue'
|
import PostCard from '~/components/PostCard.vue'
|
||||||
|
import { Pager } from 'gridsome'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Author,
|
Author,
|
||||||
PostCard
|
PostCard,
|
||||||
|
Pager
|
||||||
},
|
},
|
||||||
metaInfo: {
|
metaInfo: {
|
||||||
title: 'Home'
|
title: 'Home'
|
||||||
|
|
Loading…
Add table
Reference in a new issue