Skip to content

Commit

Permalink
Merge pull request #1567 from newrelic/clang/quick-start-layout
Browse files Browse the repository at this point in the history
Refactor landing and details pages
  • Loading branch information
roadlittledawn authored Aug 31, 2021
2 parents 0e0ba33 + 4f18a04 commit e3bffe4
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 274 deletions.
12 changes: 12 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
component: path.resolve('./src/templates/QuickstartDetails.js'),
context: {
id,
layout: 'QuickStartLayout',
},
});
});
Expand Down Expand Up @@ -156,6 +157,17 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
});
};

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);
};

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

Expand Down
33 changes: 33 additions & 0 deletions src/layouts/QuickStartLayout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { Layout, GlobalHeader } from '@newrelic/gatsby-theme-newrelic';
import PropTypes from 'prop-types';
import { css } from '@emotion/react';
import '../components/styles.scss';

const QuickStartLayout = ({ children }) => {
return (
<>
<GlobalHeader />
<Layout
css={css`
--sidebar-width: 0;
`}
>
<Layout.Main
css={css`
min-height: 100vh;
`}
>
{children}
</Layout.Main>
<Layout.Footer />
</Layout>
</>
);
};

QuickStartLayout.propTypes = {
children: PropTypes.node,
};

export default QuickStartLayout;
6 changes: 6 additions & 0 deletions src/layouts/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import React from 'react';
import MainLayout from './MainLayout';
import EmbedLayout from './EmbedLayout';
import QuickStartLayout from './QuickStartLayout';
import PropTypes from 'prop-types';

const Layout = ({ children, pageContext }) => {
const isEmbed = pageContext.layout && pageContext.layout === 'EmbedLayout';
const isQuickStart =
pageContext.layout && pageContext.layout === 'QuickStartLayout';
if (pageContext.fileRelativePath.match(/404/)) {
return children;
}
if (isEmbed) {
return <EmbedLayout>{children}</EmbedLayout>;
}
if (isQuickStart) {
return <QuickStartLayout>{children}</QuickStartLayout>;
}
return <MainLayout pageContext={pageContext}>{children}</MainLayout>;
};

Expand Down
Loading

0 comments on commit e3bffe4

Please sign in to comment.