1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-26 11:49:04 +01:00

remove promises

This commit is contained in:
Matthias Kretschmann 2019-01-04 18:51:03 +01:00
parent 232c9358b9
commit 16e903e785
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 29 additions and 41 deletions

View File

@ -21,13 +21,10 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
}
}
exports.createPages = ({ graphql, actions }) => {
exports.createPages = async ({ graphql, actions }) => {
const { createPage, createRedirect } = actions
return new Promise((resolve, reject) => {
resolve(
graphql(
`
const result = await graphql(`
{
allMarkdownRemark(sort: { fields: [fields___date], order: DESC }) {
edges {
@ -44,13 +41,9 @@ exports.createPages = ({ graphql, actions }) => {
}
}
}
`
).then(result => {
if (result.errors) {
/* eslint no-console: "off" */
console.log(result.errors)
reject(result.errors)
}
`)
if (result.errors) throw result.errors
const posts = result.data.allMarkdownRemark.edges
const numPages = Math.ceil(posts.length / itemsPerPage)
@ -63,9 +56,4 @@ exports.createPages = ({ graphql, actions }) => {
// create manual redirects
generateRedirectPages(createRedirect)
resolve()
})
)
})
}

View File

@ -32,8 +32,8 @@
"dependencies": {
"dms2dec": "^1.1.0",
"fast-exif": "^1.0.1",
"fraction.js": "^4.0.11",
"gatsby": "^2.0.80",
"fraction.js": "^4.0.12",
"gatsby": "^2.0.85",
"gatsby-image": "^2.0.25",
"gatsby-plugin-catch-links": "^2.0.9",
"gatsby-plugin-favicon": "^3.1.5",
@ -56,7 +56,7 @@
"gatsby-remark-smartypants": "^2.0.7",
"gatsby-source-filesystem": "^2.0.12",
"gatsby-source-graphql": "^2.0.8",
"gatsby-transformer-remark": "^2.1.18",
"gatsby-transformer-remark": "^2.1.19",
"gatsby-transformer-sharp": "^2.1.10",
"graphql": "^0.13.2",
"intersection-observer": "^0.5.1",
@ -91,7 +91,7 @@
"eslint-plugin-graphql": "^3.0.1",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.12.0",
"eslint-plugin-react": "^7.12.2",
"fs-extra": "^7.0.1",
"markdownlint-cli": "^0.13.0",
"npm-run-all": "^4.1.5",