mirror of
https://github.com/kremalicious/gatsby-redirect-from.git
synced 2024-06-29 00:57:42 +02:00
Merge 3580099bb1
into 50939579a6
This commit is contained in:
commit
e695b23899
|
@ -45,17 +45,28 @@ export function createPages({ graphql, actions }, pluginOptions) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const createRedirectTemplate = (from, to) => {
|
||||||
|
createRedirect({
|
||||||
|
fromPath: from,
|
||||||
|
toPath: to,
|
||||||
|
isPermanent: true,
|
||||||
|
redirectInBrowser: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Create redirects from the just constructed array
|
// Create redirects from the just constructed array
|
||||||
redirects.forEach(({ from, to }) => {
|
redirects.forEach(({ from, to }) => {
|
||||||
// iterate through all `from` array items
|
// `from` is a string when only a single value is set
|
||||||
from.forEach(from => {
|
if (typeof 'string' === from) {
|
||||||
createRedirect({
|
createRedirectTemplate(from, to)
|
||||||
fromPath: from,
|
}
|
||||||
toPath: to,
|
// otherwise `from` is a list array
|
||||||
isPermanent: true,
|
else {
|
||||||
redirectInBrowser: true
|
// iterate through all `from` array items
|
||||||
|
from.forEach(from => {
|
||||||
|
createRedirectTemplate(from, to)
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
resolve(
|
resolve(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user