1
0
mirror of https://github.com/kremalicious/gatsby-redirect-from.git synced 2024-12-22 09:13:20 +01:00

Merge pull request #10 from alirussell/master

Support alternative markdown queries (such as allMdx)
This commit is contained in:
Matthias Kretschmann 2019-06-10 23:53:00 +02:00 committed by GitHub
commit ee987af592
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,14 +1,16 @@
import chalk from 'chalk'
export function createPages({ graphql, actions }) {
export function createPages({ graphql, actions }, pluginOptions) {
const { createRedirect } = actions
const markdownQuery = pluginOptions.query || 'allMarkdownRemark'
return new Promise((resolve, reject) => {
resolve(
graphql(
`
{
allMarkdownRemark(
q: ${markdownQuery}(
filter: { frontmatter: { redirect_from: { ne: null } } }
) {
edges {
@ -30,7 +32,7 @@ export function createPages({ graphql, actions }) {
reject(result.errors)
}
const allPosts = result.data.allMarkdownRemark.edges
const allPosts = result.data.q.edges
const redirects = []