Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
feat: add path prefix part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
aswanson-nr authored and tabathadelane committed Jan 28, 2022
1 parent 1c07e7f commit 83ef94e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 673 deletions.
1 change: 1 addition & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const quote = (str) => `"${str}"`;
const resolveQuickstartSlug = require('./src/utils/resolveQuickstartSlug');

module.exports = {
pathPrefix: `/instant-observability`,
flags: {
DEV_SSR: true,
PRESERVE_WEBPACK_CACHE: true,
Expand Down
31 changes: 15 additions & 16 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require(`path`);
const resolveQuickstartSlug = require("./src/utils/resolveQuickstartSlug.js");
const resolveQuickstartSlug = require('./src/utils/resolveQuickstartSlug.js');

exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions;
Expand Down Expand Up @@ -33,34 +33,33 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
} = node;

createPage({
path: path.join(slug, "/"),
component: path.resolve("./src/templates/QuickstartDetails.js"),
path: path.join(slug, '/'),
component: path.resolve('./src/templates/QuickstartDetails.js'),
context: {
id,
layout: "QuickStartLayout",
layout: 'QuickStartLayout',
},
});
});
};

exports.onCreatePage = async ({ page, actions }) => {
const { createPage, deletePage } = actions;
const oldPage = { ...page };

if (page.path === "/instant-observability/") {
page.context.layout = "QuickStartLayout";
}
deletePage(oldPage);
createPage(page);
//const { createPage, deletePage } = actions;
//const oldPage = { ...page };
//if (page.path === '/instant-observability/') {
//page.context.layout = 'QuickStartLayout';
//}
//deletePage(oldPage);
//createPage(page);
};

exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions;

if (node.internal.type === "Quickstarts") {
if (node.internal.type === 'Quickstarts') {
createNodeField({
node,
name: "slug",
name: 'slug',
value: `${resolveQuickstartSlug(node.name, node.id)}`,
});
}
Expand All @@ -73,9 +72,9 @@ exports.onCreateWebpackConfig = ({ actions, plugins }) => {
// source instead of the node source. See the following issue for this
// recommendation:
// https://github.com/escaladesports/legacy-gatsby-plugin-prefetch-google-fonts/issues/18
plugins: [plugins.normalModuleReplacement(/^\.\/node\.js/, "./browser.js")],
plugins: [plugins.normalModuleReplacement(/^\.\/node\.js/, './browser.js')],
externals: {
tessen: "Tessen",
tessen: 'Tessen',
},
});
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"develop": "GATSBY_NEWRELIC_ENV=development gatsby develop",
"start": "gatsby develop",
"build": "GATSBY_NEWRELIC_ENV=production gatsby build",
"build:production": "yarn build --prefix-paths",
"serve": "gatsby serve",
"serve:production": "yarn serve --prefix-paths",
"clean": "gatsby clean",
"fetch-quickstarts": "node ./scripts/actions/fetch-quickstarts.js",
"build:related-content": "BUILD_RELATED_CONTENT=true yarn run build"
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import QuickStartLayout from './QuickStartLayout';
import PropTypes from 'prop-types';

const Layout = ({ children, pageContext }) => {
if (pageContext.fileRelativePath.match(/404/)) {
return children;
}
//if (pageContext.fileRelativePath.match(/404/)) {
//return children;
//}

return <QuickStartLayout>{children}</QuickStartLayout>;
};
Expand Down
Loading

0 comments on commit 83ef94e

Please sign in to comment.