mirror of
https://github.com/kremalicious/gatsby-redirect-from.git
synced 2024-12-22 17:23:24 +01:00
Merge pull request #10 from alirussell/master
Support alternative markdown queries (such as allMdx)
This commit is contained in:
commit
ee987af592
@ -1,14 +1,16 @@
|
|||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
|
|
||||||
export function createPages({ graphql, actions }) {
|
export function createPages({ graphql, actions }, pluginOptions) {
|
||||||
const { createRedirect } = actions
|
const { createRedirect } = actions
|
||||||
|
|
||||||
|
const markdownQuery = pluginOptions.query || 'allMarkdownRemark'
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
resolve(
|
resolve(
|
||||||
graphql(
|
graphql(
|
||||||
`
|
`
|
||||||
{
|
{
|
||||||
allMarkdownRemark(
|
q: ${markdownQuery}(
|
||||||
filter: { frontmatter: { redirect_from: { ne: null } } }
|
filter: { frontmatter: { redirect_from: { ne: null } } }
|
||||||
) {
|
) {
|
||||||
edges {
|
edges {
|
||||||
@ -30,7 +32,7 @@ export function createPages({ graphql, actions }) {
|
|||||||
reject(result.errors)
|
reject(result.errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
const allPosts = result.data.allMarkdownRemark.edges
|
const allPosts = result.data.q.edges
|
||||||
|
|
||||||
const redirects = []
|
const redirects = []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user