mirror of
https://github.com/kremalicious/gatsby-redirect-from.git
synced 2024-12-22 01:03:21 +01:00
handle string value
This commit is contained in:
parent
416354bf00
commit
3580099bb1
@ -43,17 +43,28 @@ export function createPages({ graphql, actions }) {
|
||||
})
|
||||
})
|
||||
|
||||
const createRedirectTemplate = (from, to) => {
|
||||
createRedirect({
|
||||
fromPath: from,
|
||||
toPath: to,
|
||||
isPermanent: true,
|
||||
redirectInBrowser: true
|
||||
})
|
||||
}
|
||||
|
||||
// Create redirects from the just constructed array
|
||||
redirects.forEach(({ from, to }) => {
|
||||
// iterate through all `from` array items
|
||||
from.forEach(from => {
|
||||
createRedirect({
|
||||
fromPath: from,
|
||||
toPath: to,
|
||||
isPermanent: true,
|
||||
redirectInBrowser: true
|
||||
// `from` is a string when only a single value is set
|
||||
if (typeof 'string' === from) {
|
||||
createRedirectTemplate(from, to)
|
||||
}
|
||||
// otherwise `from` is a list array
|
||||
else {
|
||||
// iterate through all `from` array items
|
||||
from.forEach(from => {
|
||||
createRedirectTemplate(from, to)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
resolve(
|
||||
|
Loading…
Reference in New Issue
Block a user