1
0
Fork 0

Paginated blog

This commit is contained in:
Ava Wroten 2020-03-09 22:30:49 -05:00
parent 2fc4459fd2
commit b11fff8633
3 changed files with 27 additions and 4 deletions

View file

@ -0,0 +1,13 @@
.pagination {
text-align: center;
margin: 1rem;
a {
padding: 1rem;
&.active {
color: white;
text-decoration: none;
}
}
}

View file

@ -4,4 +4,5 @@
@import 'base'; @import 'base';
@import 'code'; @import 'code';
@import 'content-box'; @import 'content-box';
@import 'utils'; @import 'pagination';
@import 'utils';

View file

@ -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'