Skip to content

Commit

Permalink
feat: Add overview template
Browse files Browse the repository at this point in the history
  • Loading branch information
timglaser committed Jun 24, 2020
1 parent 1d16e3d commit aa7474a
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/data/sidenav.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
{
"displayName": "Build apps",
"url": "/build-apps",
"children": [
{
"displayName": "Create a 'Hello, World!' app",
Expand Down
13 changes: 13 additions & 0 deletions src/markdown-pages/build-apps/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
path: '/build-apps'
title: 'Build Custom New Relic Apps'
template: 'OverviewTemplate'
description: 'Learn how to build custom New Relic applications'
---

<Intro>
This guide steps you through adding access to the New Relic time picker to a sample transaction overview application. You also add the selected time to the queries used in the application’s chart components. Start by setting up the sample application and running it locally. Then add the time picker, and some time picker features.

<Video id="inyshp3m7r" type="wistia" />

</Intro>
89 changes: 89 additions & 0 deletions src/templates/OverviewTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from 'react';
import { graphql } from 'gatsby';
import PropTypes from 'prop-types';
import { MDXRenderer } from 'gatsby-plugin-mdx';
import { MDXProvider } from '@mdx-js/react';

import { pageContext } from '../types';
import Layout from '../components/Layout';
import PageTitle from '../components/PageTitle';
import Video from '../components/Video';
import Step from '../components/Step';
import Steps from '../components/Steps';
import Caution from '../components/Caution';
import Important from '../components/Important';
import Tip from '../components/Tip';
import Intro from '../components/Intro';
import SEO from '../components/Seo';
import { BreadcrumbContext } from '../components/BreadcrumbContext';
import { PageContext } from '../components/PageContext';
import createBreadcrumbs from '../utils/create-breadcrumbs';
import pages from '../data/sidenav.json';
import styles from './OverviewTemplate.module.scss';
import CodeSnippet from '../components/CodeSnippet';

/**
* TODO
* Confirm the open ended markdown space satisfies the design
* Add filtered guide listing
* Share markdown components collection
* Move contexts to wrapRootElement (and remove pageContext)
* Remove extra div from around PageTitle
*/

const components = {
Video,
Step,
Steps,
Caution,
Important,
Tip,
Intro,
code: (props) => <CodeSnippet {...props} />,
};

const OverviewTemplate = ({ data, pageContext }) => {
const { mdx } = data;
const { frontmatter, body } = mdx;
const { title, description } = frontmatter;
const crumbs = createBreadcrumbs(frontmatter.path, pages);

return (
<PageContext.Provider value={pageContext}>
<BreadcrumbContext.Provider value={crumbs}>
<Layout>
<SEO title={title} description={description} />
<div className={styles.header}>
<PageTitle>{title}</PageTitle>
</div>
<div className={styles.mdxContainer}>
<MDXProvider components={components}>
<MDXRenderer>{body}</MDXRenderer>
</MDXProvider>
</div>
</Layout>
</BreadcrumbContext.Provider>
</PageContext.Provider>
);
};

OverviewTemplate.propTypes = {
data: PropTypes.object,
pageContext,
};

export const pageQuery = graphql`
query($path: String!) {
mdx(frontmatter: { path: { eq: $path } }) {
body
frontmatter {
duration
path
title
description
}
}
}
`;

export default OverviewTemplate;
Empty file.

0 comments on commit aa7474a

Please sign in to comment.