mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-26 11:49:04 +01:00
remove promises
This commit is contained in:
parent
232c9358b9
commit
16e903e785
@ -21,51 +21,39 @@ 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(
|
||||
`
|
||||
{
|
||||
allMarkdownRemark(sort: { fields: [fields___date], order: DESC }) {
|
||||
edges {
|
||||
node {
|
||||
fields {
|
||||
slug
|
||||
date
|
||||
}
|
||||
frontmatter {
|
||||
type
|
||||
tags
|
||||
}
|
||||
}
|
||||
}
|
||||
const result = await graphql(`
|
||||
{
|
||||
allMarkdownRemark(sort: { fields: [fields___date], order: DESC }) {
|
||||
edges {
|
||||
node {
|
||||
fields {
|
||||
slug
|
||||
date
|
||||
}
|
||||
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
|
||||
const numPages = Math.ceil(posts.length / itemsPerPage)
|
||||
if (result.errors) throw result.errors
|
||||
|
||||
// Generate posts & posts index
|
||||
generatePostPages(createPage, posts, numPages)
|
||||
const posts = result.data.allMarkdownRemark.edges
|
||||
const numPages = Math.ceil(posts.length / itemsPerPage)
|
||||
|
||||
// Generate Tag Pages
|
||||
generateTagPages(createPage, posts, numPages)
|
||||
// Generate posts & posts index
|
||||
generatePostPages(createPage, posts, numPages)
|
||||
|
||||
// create manual redirects
|
||||
generateRedirectPages(createRedirect)
|
||||
// Generate Tag Pages
|
||||
generateTagPages(createPage, posts, numPages)
|
||||
|
||||
resolve()
|
||||
})
|
||||
)
|
||||
})
|
||||
// create manual redirects
|
||||
generateRedirectPages(createRedirect)
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user