Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/assets/style/_pagination.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.pagination {
display: flex;
align-items: center;
justify-content: center;
}

.paging {
text-decoration: none;
padding: 12px 16px;
border: 1px solid #adadad;
color: grey !important;
background-color: #fff;
}

.paging.active {
color: #fff !important;
background-color: #38b2ac;
}

.paging:first-child {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}

.paging:last-child {
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
3 changes: 2 additions & 1 deletion src/assets/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
@import 'base';
@import 'code';
@import 'content-box';
@import 'utils';
@import 'utils';
@import 'pagination';
17 changes: 14 additions & 3 deletions src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
<PostCard v-for="edge in $page.posts.edges" :key="edge.node.id" :post="edge.node"/>
</div>

<!-- Pagination -->
<div class="pagination">
<Pager :info="$page.posts.pageInfo" linkClass="paging" prevLabel="Prev" nextLabel="Next" />
</div>

</Layout>
</template>

<page-query>
query {
posts: allPost(filter: { published: { eq: true }}) {
query ($page: Int) {
posts: allPost(perPage: 6, page: $page, filter: { published: { eq: true }}) @paginate {
pageInfo {
totalPages
currentPage
}
edges {
node {
id
Expand All @@ -37,11 +46,13 @@ query {
<script>
import Author from '~/components/Author.vue'
import PostCard from '~/components/PostCard.vue'
import { Pager } from 'gridsome'

export default {
components: {
Author,
PostCard
PostCard,
Pager
},
metaInfo: {
title: 'Hello, world!'
Expand Down
4 changes: 4 additions & 0 deletions src/templates/Post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export default {
return {
title: this.$page.post.title,
meta: [
{
name: 'title',
content: this.$page.post.title
},
{
name: 'description',
content: this.$page.post.description
Expand Down