mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2024-12-25 14:29:36 +01:00
Add pagination
This commit is contained in:
parent
38090a3a0f
commit
338317803e
@ -6,7 +6,7 @@ module.exports = {
|
||||
subtitle: 'Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu.',
|
||||
copyright: '© All rights reserved.',
|
||||
disqusShortname: '',
|
||||
postsPerPage: 1,
|
||||
postsPerPage: 4,
|
||||
googleAnalyticsId: 'UA-73379983-2',
|
||||
menu: [
|
||||
{
|
||||
|
@ -22,9 +22,9 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
{
|
||||
resolve: "gatsby-source-filesystem",
|
||||
resolve: 'gatsby-source-filesystem',
|
||||
options: {
|
||||
name: "assets",
|
||||
name: 'assets',
|
||||
path: `${__dirname}/static`
|
||||
}
|
||||
},
|
||||
|
@ -2,10 +2,13 @@
|
||||
|
||||
const _ = require('lodash');
|
||||
const { createFilePath } = require('gatsby-source-filesystem');
|
||||
const { fmImagesToRelative } = require('gatsby-remark-relative-images');
|
||||
|
||||
const onCreateNode = ({ node, actions, getNode }) => {
|
||||
const { createNodeField } = actions;
|
||||
|
||||
fmImagesToRelative(node);
|
||||
|
||||
if (node.internal.type === 'MarkdownRemark') {
|
||||
if (typeof node.frontmatter.path !== 'undefined') {
|
||||
createNodeField({
|
||||
@ -23,12 +26,12 @@ const onCreateNode = ({ node, actions, getNode }) => {
|
||||
}
|
||||
|
||||
if (node.frontmatter.tags) {
|
||||
const tagSlugs = node.frontmatter.tags.map((tag) => `/tags/${_.kebabCase(tag)}/`);
|
||||
const tagSlugs = node.frontmatter.tags.map((tag) => `/tag/${_.kebabCase(tag)}/`);
|
||||
createNodeField({ node, name: 'tagSlugs', value: tagSlugs });
|
||||
}
|
||||
|
||||
if (node.frontmatter.category) {
|
||||
const categorySlug = `/categories/${_.kebabCase(node.frontmatter.category)}/`;
|
||||
const categorySlug = `/category/${_.kebabCase(node.frontmatter.category)}/`;
|
||||
createNodeField({ node, name: 'categorySlug', value: categorySlug });
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ const siteConfig = require('../../config.js');
|
||||
|
||||
module.exports = async (graphql, actions) => {
|
||||
const { createPage } = actions;
|
||||
const { postsPerPage } = siteConfig;
|
||||
|
||||
const result = await graphql(`
|
||||
{
|
||||
@ -21,17 +22,22 @@ module.exports = async (graphql, actions) => {
|
||||
`);
|
||||
|
||||
_.each(result.data.allMarkdownRemark.group, (category) => {
|
||||
const numPages = Math.ceil(category.totalCount / siteConfig.postsPerPage);
|
||||
const numPages = Math.ceil(category.totalCount / postsPerPage);
|
||||
const categorySlug = `/category/${_.kebabCase(category.fieldValue)}`;
|
||||
|
||||
for (let i = 0; i < numPages; i += 1) {
|
||||
createPage({
|
||||
path: i === 0 ? `/category/${_.kebabCase(category.fieldValue)}` : `/category/${_.kebabCase(category.fieldValue)}/page/${i}`,
|
||||
path: i === 0 ? categorySlug : `${categorySlug}/page/${i}`,
|
||||
component: path.resolve('./src/templates/category-template.js'),
|
||||
context: {
|
||||
page: i,
|
||||
category: category.fieldValue,
|
||||
limit: siteConfig.postsPerPage,
|
||||
skip: i * siteConfig.postsPerPage,
|
||||
currentPage: i,
|
||||
postsLimit: postsPerPage,
|
||||
postsOffset: i * postsPerPage,
|
||||
prevPagePath: i <= 1 ? categorySlug : `${categorySlug}/page/${i - 1}`,
|
||||
nextPagePath: `/${categorySlug}/page/${i + 1}`,
|
||||
hasPrevPage: i !== 0,
|
||||
hasNextPage: i !== numPages - 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -14,16 +14,21 @@ module.exports = async (graphql, actions) => {
|
||||
}
|
||||
`);
|
||||
|
||||
const numPages = Math.ceil(result.data.allMarkdownRemark.totalCount / siteConfig.postsPerPage);
|
||||
const { postsPerPage } = siteConfig;
|
||||
const numPages = Math.ceil(result.data.allMarkdownRemark.totalCount / postsPerPage);
|
||||
|
||||
for (let i = 0; i < numPages; i += 1) {
|
||||
createPage({
|
||||
path: i === 0 ? '/' : `/page/${i}`,
|
||||
component: path.resolve('./src/templates/index-template.js'),
|
||||
context: {
|
||||
page: i,
|
||||
limit: siteConfig.postsPerPage,
|
||||
skip: i * siteConfig.postsPerPage,
|
||||
currentPage: i,
|
||||
postsLimit: postsPerPage,
|
||||
postsOffset: i * postsPerPage,
|
||||
prevPagePath: i <= 1 ? '/' : `/page/${i - 1}`,
|
||||
nextPagePath: `/page/${i + 1}`,
|
||||
hasPrevPage: i !== 0,
|
||||
hasNextPage: i !== numPages - 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ const siteConfig = require('../../config.js');
|
||||
|
||||
module.exports = async (graphql, actions) => {
|
||||
const { createPage } = actions;
|
||||
const { postsPerPage } = siteConfig;
|
||||
|
||||
const result = await graphql(`
|
||||
{
|
||||
@ -21,17 +22,22 @@ module.exports = async (graphql, actions) => {
|
||||
`);
|
||||
|
||||
_.each(result.data.allMarkdownRemark.group, (tag) => {
|
||||
const numPages = Math.ceil(tag.totalCount / siteConfig.postsPerPage);
|
||||
const numPages = Math.ceil(tag.totalCount / postsPerPage);
|
||||
const tagSlug = `/tag/${_.kebabCase(tag.fieldValue)}`;
|
||||
|
||||
for (let i = 0; i < numPages; i += 1) {
|
||||
createPage({
|
||||
path: i === 0 ? `/tag/${_.kebabCase(tag.fieldValue)}` : `/tag/${_.kebabCase(tag.fieldValue)}/page/${i}`,
|
||||
path: i === 0 ? tagSlug : `${tagSlug}/page/${i}`,
|
||||
component: path.resolve('./src/templates/tag-template.js'),
|
||||
context: {
|
||||
page: i,
|
||||
tag: tag.fieldValue,
|
||||
limit: siteConfig.postsPerPage,
|
||||
skip: i * siteConfig.postsPerPage,
|
||||
currentPage: i,
|
||||
postsLimit: postsPerPage,
|
||||
postsOffset: i * postsPerPage,
|
||||
prevPagePath: i <= 1 ? tagSlug : `${tagSlug}/page/${i - 1}`,
|
||||
nextPagePath: `${tagSlug}/page/${i + 1}`,
|
||||
hasPrevPage: i !== 0,
|
||||
hasNextPage: i !== numPages - 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
"starter"
|
||||
],
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.6",
|
||||
"bluebird": "^3.5.2",
|
||||
"codecov": "^3.1.0",
|
||||
"gatsby": "^2.0.38",
|
||||
@ -38,7 +39,7 @@
|
||||
"gatsby-plugin-feed": "^2.0.8",
|
||||
"gatsby-plugin-google-analytics": "^2.0.6",
|
||||
"gatsby-plugin-netlify": "^2.0.3",
|
||||
"gatsby-plugin-netlify-cms": "^3.0.5",
|
||||
"gatsby-plugin-netlify-cms": "^3.0.7",
|
||||
"gatsby-plugin-offline": "^2.0.6",
|
||||
"gatsby-plugin-react-helmet": "^3.0.0",
|
||||
"gatsby-plugin-sass": "^2.0.3",
|
||||
@ -48,6 +49,7 @@
|
||||
"gatsby-remark-images": "^2.0.4",
|
||||
"gatsby-remark-prismjs": "^3.0.2",
|
||||
"gatsby-remark-responsive-iframe": "^2.0.5",
|
||||
"gatsby-remark-relative-images": "^0.2.0",
|
||||
"gatsby-remark-smartypants": "^2.0.5",
|
||||
"gatsby-source-filesystem": "^2.0.3",
|
||||
"gatsby-transformer-remark": "^2.1.7",
|
||||
|
37
src/components/Pagination/Pagination.js
Normal file
37
src/components/Pagination/Pagination.js
Normal file
@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames/bind';
|
||||
import { Link } from 'gatsby';
|
||||
import { PAGINATION } from '../../constants';
|
||||
import styles from './Pagination.module.scss';
|
||||
|
||||
const cx = classNames.bind(styles);
|
||||
|
||||
const Pagination = ({
|
||||
prevPagePath,
|
||||
nextPagePath,
|
||||
hasNextPage,
|
||||
hasPrevPage
|
||||
}) => {
|
||||
const prevClassName = cx({
|
||||
'pagination__prev-link': true,
|
||||
'pagination__prev-link--disable': !hasPrevPage
|
||||
});
|
||||
|
||||
const nextClassName = cx({
|
||||
'pagination__next-link': true,
|
||||
'pagination__next-link--disable': !hasNextPage
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={styles['pagination']}>
|
||||
<div className={styles['pagination__prev']}>
|
||||
<Link rel="prev" to={prevPagePath} className={prevClassName}>{PAGINATION.PREV_PAGE}</Link>
|
||||
</div>
|
||||
<div className={styles['pagination__next']}>
|
||||
<Link rel="next" to={nextPagePath} className={nextClassName}>{PAGINATION.NEXT_PAGE}</Link>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
export default Pagination;
|
54
src/components/Pagination/Pagination.module.scss
Normal file
54
src/components/Pagination/Pagination.module.scss
Normal file
@ -0,0 +1,54 @@
|
||||
@import '../../assets/scss/variables';
|
||||
@import '../../assets/scss/mixins';
|
||||
|
||||
.pagination {
|
||||
@include margin-top(2);
|
||||
display: flex;
|
||||
|
||||
&__prev {
|
||||
width: 50%;
|
||||
text-align: left;
|
||||
|
||||
&-link {
|
||||
color: $color-secondary;
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
&--disable {
|
||||
pointer-events: none;
|
||||
color: lighten($color-gray, 20%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&__next {
|
||||
width: 50%;
|
||||
text-align: right;
|
||||
|
||||
&-link {
|
||||
color: $color-secondary;
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
&--disable {
|
||||
pointer-events: none;
|
||||
color: lighten($color-gray, 20%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
17
src/components/Pagination/Pagination.test.js
Normal file
17
src/components/Pagination/Pagination.test.js
Normal file
@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import Pagination from './Pagination';
|
||||
|
||||
describe('Pagination', () => {
|
||||
const props = {
|
||||
prevPagePath: '/page/1',
|
||||
nextPagePath: '/page/3',
|
||||
hasNextPage: true,
|
||||
hasPrevPage: true
|
||||
};
|
||||
|
||||
it('renders correctly', () => {
|
||||
const tree = renderer.create(<Pagination {...props} />).toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
@ -0,0 +1,28 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Pagination renders correctly 1`] = `
|
||||
<div
|
||||
className="pagination"
|
||||
>
|
||||
<div
|
||||
className="pagination__prev"
|
||||
>
|
||||
<Link
|
||||
className="pagination__prev-link"
|
||||
to="/page/1"
|
||||
>
|
||||
← PREV
|
||||
</Link>
|
||||
</div>
|
||||
<div
|
||||
className="pagination__next"
|
||||
>
|
||||
<Link
|
||||
className="pagination__next-link"
|
||||
to="/page/3"
|
||||
>
|
||||
→ NEXT
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
1
src/components/Pagination/index.js
Normal file
1
src/components/Pagination/index.js
Normal file
@ -0,0 +1 @@
|
||||
export { default } from './Pagination';
|
@ -1 +1,2 @@
|
||||
export { default as ICONS } from './icons';
|
||||
export { default as PAGINATION } from './pagination';
|
||||
|
6
src/constants/pagination.js
Normal file
6
src/constants/pagination.js
Normal file
@ -0,0 +1,6 @@
|
||||
const PAGINATION = {
|
||||
PREV_PAGE: '← PREV',
|
||||
NEXT_PAGE: '→ NEXT'
|
||||
};
|
||||
|
||||
export default PAGINATION;
|
@ -121,6 +121,30 @@ exports[`CategoryTemplate renders correctly 1`] = `
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="pagination"
|
||||
>
|
||||
<div
|
||||
className="pagination__prev"
|
||||
>
|
||||
<Link
|
||||
className="pagination__prev-link"
|
||||
to="/page/1"
|
||||
>
|
||||
← PREV
|
||||
</Link>
|
||||
</div>
|
||||
<div
|
||||
className="pagination__next"
|
||||
>
|
||||
<Link
|
||||
className="pagination__next-link"
|
||||
to="/page/3"
|
||||
>
|
||||
→ NEXT
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -116,6 +116,30 @@ exports[`IndexTemplate renders correctly 1`] = `
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="pagination"
|
||||
>
|
||||
<div
|
||||
className="pagination__prev"
|
||||
>
|
||||
<Link
|
||||
className="pagination__prev-link"
|
||||
to="/page/1"
|
||||
>
|
||||
← PREV
|
||||
</Link>
|
||||
</div>
|
||||
<div
|
||||
className="pagination__next"
|
||||
>
|
||||
<Link
|
||||
className="pagination__next-link"
|
||||
to="/page/3"
|
||||
>
|
||||
→ NEXT
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -121,6 +121,30 @@ exports[`TagTemplate renders correctly 1`] = `
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="pagination"
|
||||
>
|
||||
<div
|
||||
className="pagination__prev"
|
||||
>
|
||||
<Link
|
||||
className="pagination__prev-link"
|
||||
to="/page/1"
|
||||
>
|
||||
← PREV
|
||||
</Link>
|
||||
</div>
|
||||
<div
|
||||
className="pagination__next"
|
||||
>
|
||||
<Link
|
||||
className="pagination__next-link"
|
||||
to="/page/3"
|
||||
>
|
||||
→ NEXT
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -4,6 +4,7 @@ import Layout from '../components/Layout';
|
||||
import Sidebar from '../components/Sidebar';
|
||||
import Feed from '../components/Feed';
|
||||
import Page from '../components/Page';
|
||||
import Pagination from '../components/Pagination';
|
||||
|
||||
const CategoryTemplate = ({ data, pageContext }) => {
|
||||
const {
|
||||
@ -13,24 +14,34 @@ const CategoryTemplate = ({ data, pageContext }) => {
|
||||
|
||||
const {
|
||||
category,
|
||||
page
|
||||
currentPage,
|
||||
prevPagePath,
|
||||
nextPagePath,
|
||||
hasPrevPage,
|
||||
hasNextPage,
|
||||
} = pageContext;
|
||||
|
||||
const { edges } = data.allMarkdownRemark;
|
||||
const pageTitle = page > 0 ? `${category} - Page ${page} - ${siteTitle}` : `${category} - ${siteTitle}`;
|
||||
const pageTitle = currentPage > 0 ? `${category} - Page ${currentPage} - ${siteTitle}` : `${category} - ${siteTitle}`;
|
||||
|
||||
return (
|
||||
<Layout title={pageTitle} description={siteSubtitle}>
|
||||
<Sidebar />
|
||||
<Page title={category}>
|
||||
<Feed edges={edges} />
|
||||
<Pagination
|
||||
prevPagePath={prevPagePath}
|
||||
nextPagePath={nextPagePath}
|
||||
hasPrevPage={hasPrevPage}
|
||||
hasNextPage={hasNextPage}
|
||||
/>
|
||||
</Page>
|
||||
</Layout>
|
||||
);
|
||||
};
|
||||
|
||||
export const query = graphql`
|
||||
query CategoryPage($category: String, $limit: Int!, $skip: Int!) {
|
||||
query CategoryPage($category: String, $postsLimit: Int!, $postsOffset: Int!) {
|
||||
site {
|
||||
siteMetadata {
|
||||
title
|
||||
@ -38,8 +49,8 @@ export const query = graphql`
|
||||
}
|
||||
}
|
||||
allMarkdownRemark(
|
||||
limit: $limit,
|
||||
skip: $skip,
|
||||
limit: $postsLimit,
|
||||
skip: $postsOffset,
|
||||
filter: { frontmatter: { category: { eq: $category }, layout: { eq: "post" }, draft: { ne: true } } },
|
||||
sort: { order: DESC, fields: [frontmatter___date] }
|
||||
){
|
||||
|
@ -56,7 +56,11 @@ describe('CategoryTemplate', () => {
|
||||
},
|
||||
pageContext: {
|
||||
category: 'test',
|
||||
page: 1
|
||||
currentPage: 1,
|
||||
prevPagePath: '/page/1',
|
||||
nextPagePath: '/page/3',
|
||||
hasNextPage: true,
|
||||
hasPrevPage: true
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,7 @@ import Layout from '../components/Layout';
|
||||
import Sidebar from '../components/Sidebar';
|
||||
import Feed from '../components/Feed';
|
||||
import Page from '../components/Page';
|
||||
import Pagination from '../components/Pagination';
|
||||
|
||||
const IndexTemplate = ({ data, pageContext }) => {
|
||||
const {
|
||||
@ -11,22 +12,35 @@ const IndexTemplate = ({ data, pageContext }) => {
|
||||
subtitle: siteSubtitle
|
||||
} = data.site.siteMetadata;
|
||||
|
||||
const { page } = pageContext;
|
||||
const {
|
||||
currentPage,
|
||||
hasNextPage,
|
||||
hasPrevPage,
|
||||
prevPagePath,
|
||||
nextPagePath
|
||||
} = pageContext;
|
||||
|
||||
const { edges } = data.allMarkdownRemark;
|
||||
const pageTitle = page > 0 ? `Posts - Page ${page} - ${siteTitle}` : siteTitle;
|
||||
const pageTitle = currentPage > 0 ? `Posts - Page ${currentPage} - ${siteTitle}` : siteTitle;
|
||||
|
||||
return (
|
||||
<Layout title={`${pageTitle}`} description={siteSubtitle}>
|
||||
<Layout title={pageTitle} description={siteSubtitle}>
|
||||
<Sidebar />
|
||||
<Page>
|
||||
<Feed edges={edges} />
|
||||
<Pagination
|
||||
prevPagePath={prevPagePath}
|
||||
nextPagePath={nextPagePath}
|
||||
hasPrevPage={hasPrevPage}
|
||||
hasNextPage={hasNextPage}
|
||||
/>
|
||||
</Page>
|
||||
</Layout>
|
||||
);
|
||||
};
|
||||
|
||||
export const query = graphql`
|
||||
query IndexTemplate($limit: Int!, $skip: Int!) {
|
||||
query IndexTemplate($postsLimit: Int!, $postsOffset: Int!) {
|
||||
site {
|
||||
siteMetadata {
|
||||
title
|
||||
@ -34,8 +48,8 @@ export const query = graphql`
|
||||
}
|
||||
}
|
||||
allMarkdownRemark(
|
||||
limit: $limit,
|
||||
skip: $skip,
|
||||
limit: $postsLimit,
|
||||
skip: $postsOffset,
|
||||
filter: { frontmatter: { layout: { eq: "post" }, draft: { ne: true } } },
|
||||
sort: { order: DESC, fields: [frontmatter___date] }
|
||||
){
|
||||
|
@ -45,7 +45,11 @@ describe('IndexTemplate', () => {
|
||||
}
|
||||
},
|
||||
pageContext: {
|
||||
page: 1
|
||||
currentPage: 1,
|
||||
prevPagePath: '/page/1',
|
||||
nextPagePath: '/page/3',
|
||||
hasNextPage: true,
|
||||
hasPrevPage: true
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,7 @@ import Layout from '../components/Layout';
|
||||
import Sidebar from '../components/Sidebar';
|
||||
import Feed from '../components/Feed';
|
||||
import Page from '../components/Page';
|
||||
import Pagination from '../components/Pagination';
|
||||
|
||||
const TagTemplate = ({ data, pageContext }) => {
|
||||
const {
|
||||
@ -12,25 +13,35 @@ const TagTemplate = ({ data, pageContext }) => {
|
||||
} = data.site.siteMetadata;
|
||||
|
||||
const {
|
||||
page,
|
||||
tag
|
||||
tag,
|
||||
currentPage,
|
||||
prevPagePath,
|
||||
nextPagePath,
|
||||
hasPrevPage,
|
||||
hasNextPage
|
||||
} = pageContext;
|
||||
|
||||
const { edges } = data.allMarkdownRemark;
|
||||
const pageTitle = page > 0 ? `All Posts tagged as "${tag}" - Page ${page} - ${siteTitle}` : `All Posts tagged as "${tag}" - ${siteTitle}`;
|
||||
const pageTitle = currentPage > 0 ? `All Posts tagged as "${tag}" - Page ${currentPage} - ${siteTitle}` : `All Posts tagged as "${tag}" - ${siteTitle}`;
|
||||
|
||||
return (
|
||||
<Layout title={pageTitle} description={siteSubtitle}>
|
||||
<Sidebar />
|
||||
<Page title={tag}>
|
||||
<Feed edges={edges} />
|
||||
<Pagination
|
||||
prevPagePath={prevPagePath}
|
||||
nextPagePath={nextPagePath}
|
||||
hasPrevPage={hasPrevPage}
|
||||
hasNextPage={hasNextPage}
|
||||
/>
|
||||
</Page>
|
||||
</Layout>
|
||||
);
|
||||
};
|
||||
|
||||
export const query = graphql`
|
||||
query TagPage($tag: String, $limit: Int!, $skip: Int!) {
|
||||
query TagPage($tag: String, $postsLimit: Int!, $postsOffset: Int!) {
|
||||
site {
|
||||
siteMetadata {
|
||||
title
|
||||
@ -38,8 +49,8 @@ export const query = graphql`
|
||||
}
|
||||
}
|
||||
allMarkdownRemark(
|
||||
limit: $limit,
|
||||
skip: $skip,
|
||||
limit: $postsLimit,
|
||||
skip: $postsOffset,
|
||||
filter: { frontmatter: { tags: { in: [$tag] }, layout: { eq: "post" }, draft: { ne: true } } },
|
||||
sort: { order: DESC, fields: [frontmatter___date] }
|
||||
){
|
||||
|
@ -56,7 +56,11 @@ describe('TagTemplate', () => {
|
||||
},
|
||||
pageContext: {
|
||||
tag: 'test',
|
||||
page: 1
|
||||
currentPage: 1,
|
||||
prevPagePath: '/page/1',
|
||||
nextPagePath: '/page/3',
|
||||
hasNextPage: true,
|
||||
hasPrevPage: true
|
||||
}
|
||||
};
|
||||
|
||||
|
86
yarn.lock
86
yarn.lock
@ -1920,7 +1920,7 @@ babel-plugin-transform-strict-mode@^6.24.1:
|
||||
babel-runtime "^6.22.0"
|
||||
babel-types "^6.24.1"
|
||||
|
||||
babel-polyfill@^6.20.0:
|
||||
babel-polyfill@^6.20.0, babel-polyfill@^6.26.0:
|
||||
version "6.26.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
|
||||
dependencies:
|
||||
@ -2682,7 +2682,7 @@ charenc@~0.0.1:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
|
||||
|
||||
cheerio@^1.0.0-rc.2:
|
||||
cheerio@1.0.0-rc.2, cheerio@^1.0.0-rc.2:
|
||||
version "1.0.0-rc.2"
|
||||
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.2.tgz#4b9f53a81b27e4d5dac31c0ffd0cfa03cc6830db"
|
||||
dependencies:
|
||||
@ -2767,6 +2767,10 @@ class-utils@^0.3.5:
|
||||
isobject "^3.0.0"
|
||||
static-extend "^0.1.1"
|
||||
|
||||
classnames@^2.2.6:
|
||||
version "2.2.6"
|
||||
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
|
||||
|
||||
clean-css@4.2.x:
|
||||
version "4.2.1"
|
||||
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.1.tgz#2d411ef76b8569b6d0c84068dabe85b0aa5e5c17"
|
||||
@ -3495,6 +3499,12 @@ cyclist@~0.2.2:
|
||||
version "0.2.2"
|
||||
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640"
|
||||
|
||||
d@1:
|
||||
version "1.0.0"
|
||||
resolved "http://registry.npmjs.org/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f"
|
||||
dependencies:
|
||||
es5-ext "^0.10.9"
|
||||
|
||||
damerau-levenshtein@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.4.tgz#03191c432cb6eea168bb77f3a55ffdccb8978514"
|
||||
@ -3700,6 +3710,14 @@ deep-is@~0.1.3:
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
|
||||
|
||||
deep-map@1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/deep-map/-/deep-map-1.5.0.tgz#eaa595cb81783ca2800f26a42e09f16e7d4fb890"
|
||||
dependencies:
|
||||
es6-weak-map "^2.0.2"
|
||||
lodash "^4.17.4"
|
||||
tslib "^1.6.0"
|
||||
|
||||
deepmerge@^2.0.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170"
|
||||
@ -4255,6 +4273,22 @@ es-to-primitive@^1.1.1:
|
||||
is-date-object "^1.0.1"
|
||||
is-symbol "^1.0.2"
|
||||
|
||||
es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14:
|
||||
version "0.10.46"
|
||||
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.46.tgz#efd99f67c5a7ec789baa3daa7f79870388f7f572"
|
||||
dependencies:
|
||||
es6-iterator "~2.0.3"
|
||||
es6-symbol "~3.1.1"
|
||||
next-tick "1"
|
||||
|
||||
es6-iterator@^2.0.1, es6-iterator@~2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7"
|
||||
dependencies:
|
||||
d "1"
|
||||
es5-ext "^0.10.35"
|
||||
es6-symbol "^3.1.1"
|
||||
|
||||
es6-promise@^3.0.2:
|
||||
version "3.3.1"
|
||||
resolved "http://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz#a08cdde84ccdbf34d027a1451bc91d4bcd28a613"
|
||||
@ -4263,6 +4297,22 @@ es6-promisify@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-6.0.0.tgz#b526a75eaa5ca600e960bf3d5ad98c40d75c7203"
|
||||
|
||||
es6-symbol@^3.1.1, es6-symbol@~3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77"
|
||||
dependencies:
|
||||
d "1"
|
||||
es5-ext "~0.10.14"
|
||||
|
||||
es6-weak-map@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f"
|
||||
dependencies:
|
||||
d "1"
|
||||
es5-ext "^0.10.14"
|
||||
es6-iterator "^2.0.1"
|
||||
es6-symbol "^3.1.1"
|
||||
|
||||
escape-html@~1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
|
||||
@ -5291,9 +5341,9 @@ gatsby-plugin-google-analytics@^2.0.6:
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0"
|
||||
|
||||
gatsby-plugin-netlify-cms@^3.0.5:
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/gatsby-plugin-netlify-cms/-/gatsby-plugin-netlify-cms-3.0.5.tgz#2508424c43ec432163656b63e46c6ea9ff8a29f9"
|
||||
gatsby-plugin-netlify-cms@^3.0.7:
|
||||
version "3.0.7"
|
||||
resolved "https://registry.yarnpkg.com/gatsby-plugin-netlify-cms/-/gatsby-plugin-netlify-cms-3.0.7.tgz#d5da2b65611667cae7ca01d49fe8d4df0944a639"
|
||||
dependencies:
|
||||
friendly-errors-webpack-plugin "^1.7.0"
|
||||
html-webpack-exclude-assets-plugin "^0.0.7"
|
||||
@ -5416,6 +5466,18 @@ gatsby-remark-prismjs@^3.0.2:
|
||||
parse-numeric-range "^0.0.2"
|
||||
unist-util-visit "^1.3.0"
|
||||
|
||||
gatsby-remark-relative-images@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/gatsby-remark-relative-images/-/gatsby-remark-relative-images-0.2.0.tgz#a8a88186d38a2c5ab0a8a9f926df7abcd1dd2d55"
|
||||
dependencies:
|
||||
babel-polyfill "^6.26.0"
|
||||
cheerio "1.0.0-rc.2"
|
||||
deep-map "1.5.0"
|
||||
is-relative-url "2.0.0"
|
||||
lodash "4.17.5"
|
||||
slash "2.0.0"
|
||||
unist-util-select "1.5.0"
|
||||
|
||||
gatsby-remark-responsive-iframe@^2.0.5:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/gatsby-remark-responsive-iframe/-/gatsby-remark-responsive-iframe-2.0.5.tgz#a8ee276e38ce92f98746916c01d1c30e328048fd"
|
||||
@ -7132,7 +7194,7 @@ is-regexp@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069"
|
||||
|
||||
is-relative-url@^2.0.0:
|
||||
is-relative-url@2.0.0, is-relative-url@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-relative-url/-/is-relative-url-2.0.0.tgz#72902d7fe04b3d4792e7db15f9db84b7204c9cef"
|
||||
dependencies:
|
||||
@ -8227,6 +8289,10 @@ lodash.uniq@^4.5.0:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
||||
|
||||
lodash@4.17.5:
|
||||
version "4.17.5"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
|
||||
|
||||
lodash@^4.0.0, lodash@^4.1.1, lodash@^4.11.1, lodash@^4.12.0, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1, lodash@~4.17.10:
|
||||
version "4.17.11"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
|
||||
@ -9083,7 +9149,7 @@ netlify-identity-widget@^1.4.11:
|
||||
version "1.4.14"
|
||||
resolved "https://registry.yarnpkg.com/netlify-identity-widget/-/netlify-identity-widget-1.4.14.tgz#32539380b85ce98881f3cea2d59111cb031ea994"
|
||||
|
||||
next-tick@^1.0.0:
|
||||
next-tick@1, next-tick@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
|
||||
|
||||
@ -12047,6 +12113,10 @@ sitemap@^1.12.0:
|
||||
underscore "^1.7.0"
|
||||
url-join "^1.1.0"
|
||||
|
||||
slash@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
|
||||
|
||||
slash@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
|
||||
@ -13403,7 +13473,7 @@ unist-util-remove-position@^1.0.0, unist-util-remove-position@^1.1.2:
|
||||
dependencies:
|
||||
unist-util-visit "^1.1.0"
|
||||
|
||||
unist-util-select@^1.5.0:
|
||||
unist-util-select@1.5.0, unist-util-select@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/unist-util-select/-/unist-util-select-1.5.0.tgz#a93c2be8c0f653827803b81331adec2aa24cd933"
|
||||
dependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user