1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-29 23:48:11 +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,51 +21,39 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
} }
} }
exports.createPages = ({ graphql, actions }) => { exports.createPages = async ({ graphql, actions }) => {
const { createPage, createRedirect } = actions const { createPage, createRedirect } = actions
return new Promise((resolve, reject) => { const result = await graphql(`
resolve( {
graphql( allMarkdownRemark(sort: { fields: [fields___date], order: DESC }) {
` edges {
{ node {
allMarkdownRemark(sort: { fields: [fields___date], order: DESC }) { fields {
edges { slug
node { date
fields { }
slug frontmatter {
date type
} tags
frontmatter {
type
tags
}
}
}
} }
} }
`
).then(result => {
if (result.errors) {
/* eslint no-console: "off" */
console.log(result.errors)
reject(result.errors)
} }
}
}
`)
const posts = result.data.allMarkdownRemark.edges if (result.errors) throw result.errors
const numPages = Math.ceil(posts.length / itemsPerPage)
// Generate posts & posts index const posts = result.data.allMarkdownRemark.edges
generatePostPages(createPage, posts, numPages) const numPages = Math.ceil(posts.length / itemsPerPage)
// Generate Tag Pages // Generate posts & posts index
generateTagPages(createPage, posts, numPages) generatePostPages(createPage, posts, numPages)
// create manual redirects // Generate Tag Pages
generateRedirectPages(createRedirect) generateTagPages(createPage, posts, numPages)
resolve() // create manual redirects
}) generateRedirectPages(createRedirect)
)
})
} }

View File

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