Skip to content

Commit

Permalink
add redirect_to
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour committed May 20, 2020
1 parent 3d92194 commit 73b5123
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions gatsby-template/gatsby-node.js
Expand Up @@ -13,6 +13,7 @@ exports.createSchemaCustomization = ({ actions }) => {
canonical_link: String
categories: [String]
redirect_from: [String]
redirect_to: String
}
type MediumMdxFields {
slug: String
Expand Down
14 changes: 14 additions & 0 deletions gatsby-theme/gatsby-node.js
Expand Up @@ -48,6 +48,7 @@ exports.createPages = (
}
frontmatter {
redirect_from
redirect_to
title
}
}
Expand Down Expand Up @@ -106,6 +107,19 @@ exports.createPages = (
})
})
}

if (
node.frontmatter &&
node.frontmatter.redirect_to &&
node.frontmatter.redirect_to.length
) {
createRedirect({
fromPath: pagePath,
toPath: node.frontmatter.redirect_to,
isPermanent: true,
redirectInBrowser: true,
})
}
})
})
}
2 changes: 1 addition & 1 deletion gatsby-theme/package.json
@@ -1,7 +1,7 @@
{
"name": "gatsby-theme-medium-to-own-blog",
"description": "Gatsby theme for Medium-to-own-blog",
"version": "0.2.14",
"version": "0.2.15",
"author": "Mathieu Dutour <mathieu@dutour.me>",
"repository": {
"type": "git",
Expand Down

0 comments on commit 73b5123

Please sign in to comment.