Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meetups pagination #69

Merged
merged 14 commits into from
Aug 23, 2018
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ _site/crash.log
node_modules
*.log
public
.cache
.idea
13 changes: 7 additions & 6 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
module.exports = {
siteMetadata: {
title: `JavaScript Zagreb`
title: 'JavaScript Zagreb'
},
plugins: [
`gatsby-plugin-react-helmet`,
'gatsby-plugin-styled-components',
'gatsby-plugin-react-helmet',
'gatsby-transformer-remark',
{
resolve: `gatsby-plugin-google-fonts`,
resolve: 'gatsby-plugin-google-fonts',
options: {
fonts: [`Oswald`]
fonts: ['Oswald']
}
},
{
resolve: `gatsby-source-filesystem`,
resolve: 'gatsby-source-filesystem',
options: {
name: `src`,
name: 'src',
path: `${__dirname}/src`
}
}
Expand Down
46 changes: 40 additions & 6 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
const createPaginatedPages = require('gatsby-paginate')
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
graphql(`
{
site {
siteMetadata {
title
}
}
posts: allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
filter: { fileAbsolutePath: { regex: "/(slides)/.*.md$/" } }
) {
totalCount
edges {
node {
id
html
frontmatter {
date(formatString: "DD.MM.YYYY.")
title
}
}
}
}
}
`).then(result => {
createPaginatedPages({
edges: result.data.posts.edges,
createPage: createPage,
pageTemplate: 'src/templates/slides/index.js',
pathPrefix: 'slides',
pageLength: 3
})

// You can delete this file if you're not using it
resolve()
})
})
}
Loading