-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13e7eef
commit e84f1e8
Showing
7 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const path = require('path'); | ||
|
||
exports.createPages = async ({ actions, graphql, reporter }) => { | ||
const { createPage } = actions; | ||
|
||
const { data } = await graphql(` | ||
query MyQuery { | ||
allMdx(filter: { frontmatter: { template: { eq: "GuideTemplate" } } }) { | ||
nodes { | ||
fields { | ||
fileRelativePath | ||
slug | ||
} | ||
frontmatter { | ||
title | ||
path | ||
} | ||
body | ||
} | ||
} | ||
} | ||
`); | ||
|
||
data.allMdx.nodes.forEach((node) => { | ||
const { | ||
frontmatter, | ||
fields: { fileRelativePath, slug }, | ||
body, | ||
} = node; | ||
const nodePath = frontmatter.path || slug; | ||
const pagePath = path.join(nodePath, 'embed'); | ||
const contentSourcePath = nodePath; | ||
|
||
createPage({ | ||
path: pagePath, | ||
component: path.resolve(`src/templates/embedPage.js`), | ||
context: { | ||
slug, | ||
fileRelativePath, | ||
contentSourcePath, | ||
layout: 'EmbedLayout', | ||
}, | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Layout } from '@newrelic/gatsby-theme-newrelic'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const EmbedLayout = ({ children, pageContext }) => { | ||
return <Layout.Main>{children}</Layout.Main>; | ||
}; | ||
|
||
EmbedLayout.propTypes = { | ||
children: PropTypes.node, | ||
pageContext: PropTypes.object, | ||
}; | ||
|
||
export default EmbedLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { graphql } from 'gatsby'; | ||
import PropTypes from 'prop-types'; | ||
import PageLayout from '../components/PageLayout'; | ||
|
||
const EmbedPage = ({ data }) => { | ||
const { mdx } = data; | ||
const { frontmatter, body } = mdx; | ||
const { title } = frontmatter; | ||
|
||
return ( | ||
<> | ||
<h1>{title}</h1> | ||
<PageLayout.MarkdownContent>{body}</PageLayout.MarkdownContent> | ||
</> | ||
); | ||
}; | ||
|
||
export const pageQuery = graphql` | ||
query($contentSourcePath: String!) { | ||
mdx(frontmatter: { path: { eq: $contentSourcePath } }) { | ||
body | ||
frontmatter { | ||
title | ||
} | ||
} | ||
} | ||
`; | ||
|
||
EmbedPage.propTypes = { | ||
data: PropTypes.object, | ||
}; | ||
|
||
export default EmbedPage; |