Skip to content

Commit

Permalink
feat(redirects): support redirecting developer urls to external sites
Browse files Browse the repository at this point in the history
chore: remove mdx file to test if redirect works

fix: add prop to redirect in browser to see if it works in previews

chore: test to see if trailing slash works without redirecting in browser

chore: restore file, empty out redirects json
  • Loading branch information
roadlittledawn committed May 25, 2022
1 parent d24bae7 commit b5df19b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require(`path`);
const { execSync } = require('child_process');
const { createFilePath } = require('gatsby-source-filesystem');
const resolveQuickstartSlug = require('./src/utils/resolveQuickstartSlug.js');
const externalRedirects = require('./src/data/external-redirects.json');

const kebabCase = (string) =>
string
Expand Down Expand Up @@ -83,6 +84,19 @@ exports.createPages = async ({ actions, graphql, reporter }) => {

const { allMdx, allNewRelicSdkComponent, allNewRelicSdkApi } = result.data;

if (externalRedirects.length > 0) {
externalRedirects.forEach(({ url, paths }) => {
paths.forEach((path) => {
createRedirect({
fromPath: path,
toPath: url,
isPermanent: true,
redirectInBrowser: true,
});
});
});
}

createRedirect({
fromPath: `/instant-observability/`,
toPath: `https://newrelic.com/instant-observability`,
Expand Down
1 change: 1 addition & 0 deletions src/data/external-redirects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]

0 comments on commit b5df19b

Please sign in to comment.