Skip to content

Commit

Permalink
feat(archive-pagination): wired up initial pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Jun 16, 2020
1 parent 2fcf53e commit a1346e1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 1 addition & 3 deletions gatsby/create-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const path = require('path');

function createMeetingPages(meetings, createPage) {
meetings.forEach(({node}) => {
if (!node.fields || !node.fields.slug) return;

createPage({
path: node.fields.slug,
component: path.resolve('./src/templates/meeting.js'),
Expand Down Expand Up @@ -47,7 +45,7 @@ module.exports = async ({graphql, actions}) => {
}
`);

const meetings = result.data.allMarkdownRemark.edges;
const meetings = result.data.allMarkdownRemark.edges.filter(edge => edge.node.fields.slug);

createMeetingPages(meetings, createPage);
createArchiveListPage(meetings, createPage);
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"remark-frontmatter": "2.0.0"
},
"dependencies": {
"@dsmjs/components": "4.0.2",
"@dsmjs/components": "5.0.0-beta.1",
"gatsby": "2.19.12",
"gatsby-link": "2.4.2",
"gatsby-plugin-glamor": "2.3.4",
Expand Down
12 changes: 8 additions & 4 deletions src/templates/archive.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import {arrayOf, shape, string} from 'prop-types';
import {arrayOf, number, shape, string} from 'prop-types';
import {graphql} from 'gatsby';
import {Archive as ArchivePage} from '@dsmjs/components';
import Layout from '../components/layout';

export default function Archive({data}) {
export default function Archive({data, pageContext: {totalPages, currentPage}}) {
const meetings = data.allMarkdownRemark.edges;

return (
<Layout>
<ArchivePage meetings={meetings} />
<ArchivePage meetings={meetings} totalPages={totalPages} currentPage={currentPage} />
</Layout>
);
}
Expand All @@ -26,7 +26,11 @@ Archive.propTypes = {
})
}))
})
}
},
pageContext: shape({
totalPages: number.isRequired,
currentPage: number.isRequired
}).isRequired
};

export const meetingsQuery = graphql`
Expand Down

0 comments on commit a1346e1

Please sign in to comment.