Skip to content

Commit

Permalink
chore: Pull examples and description from graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 28, 2020
1 parent 74c701e commit 68ec65e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/templates/ComponentReferenceTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,18 @@ const previewStyles = {

const ComponentReferenceTemplate = ({ data }) => {
const {
newRelicSdkComponent: { name },
newRelicSdkComponent: { name, description, examples },
} = data;

const {
examples = [],
description: componentDescription,
methods = [],
usage = '',
typeDefs = [],
propTypes = [],
} = useComponentDoc(name) ?? {};
const { methods = [], usage = '', typeDefs = [], propTypes = [] } =
useComponentDoc(name) ?? {};

return (
<Layout>
<SEO title={name} />
<PageTitle>{name}</PageTitle>
<section className={cx(templateStyles.section, 'intro-text')}>
<Markdown source={componentDescription} />
<Markdown source={description} />
</section>

<section className={templateStyles.section}>
Expand All @@ -76,7 +70,7 @@ const ComponentReferenceTemplate = ({ data }) => {
key={i}
useToastManager={name === 'Toast'}
className={styles.componentExample}
example={example}
example={{ ...example, options: { live: example.preview } }}
previewStyle={previewStyles[name]}
/>
))}
Expand Down Expand Up @@ -128,6 +122,12 @@ export const pageQuery = graphql`
query($path: String!) {
newRelicSdkComponent(fields: { slug: { eq: $path } }) {
name
description
examples {
label
sourceCode
preview
}
}
}
`;
Expand Down

0 comments on commit 68ec65e

Please sign in to comment.