Nogn provides a Pager
component based off of the native Gridsome Pager component. The eventual hope will be to not need this custom component.
Install the component in your category template or page
<template>
<div>
<!-- other template code -->
<Pager :info="$context.nognPageInfo" />
</div>
</template>
<script>
import Pager from '@nogn/gridsome-source-craft/dist/Pager'
export default {
components: { Pager }
}
</script>
src/pages/
file
Pagination in a Note the use of the limit
and nognOffset
<page-query>
query ($nognOffset: Int = 0) {
craft {
entries (limit: 2, offset: $nognOffset) {
# examples of whatever fields are needed
id
title
}
}
}
</page-query>
src/template
category file
Pagination in a Note the use of $uid
, $id
and $nognOffet
<page-query>
query ($uid: [String], $id: [Int], $nognOffset: Int = 0) {
craft {
category (uid: $uid) {
# examples of whatever fields are needed
id
title
}
entries (relatedTo: $id, limit: 10, offset: $nognOffset) {
# examples of whatever fields are needed
title
}
}
}
</page-query>
Component arguments
These follow the conventions of the Gridsome Pager component
Property | Default | |
---|---|---|
info | required | Page info from GraphQL result with totalPages |
showLinks | true | Show navigation links |
showNavigation | true | Show previous and next links |
range | 5 | How many links to show |
linkClass | Add custom classes to the links | |
firstLabel | « | |
prevLabel | ‹ | |
nextLabel | › | |
lastLabel | » | |
ariaLabel | Pagination | Navigation |
ariaLinkLabel | Go to page %n | |
ariaFirstLabel | Go to first page | |
ariaCurrentLabel | Current page. Page %n | |
ariaPrevLabel | Go to previous page. Page %n | |
ariaNextLabel | Go to next page. Page %n | |
ariaLastLabel | Go to last page. Page %n |