Skip to content

Commit

Permalink
feat: added component description
Browse files Browse the repository at this point in the history
  • Loading branch information
zstix committed Jun 2, 2020
1 parent 89b4a8d commit 01b173f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/templates/ReferenceTemplate.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import React, { useState } from 'react';
import { graphql } from 'gatsby';
import PropTypes from 'prop-types';
import ReactMarkdown from 'react-markdown';
import Container from '../components/Container';
import Layout from '../components/Layout';
import Sidebar from '../components/Sidebar';
import SEO from '../components/Seo';
import useSdk from '../hooks/useSdk';

import pages from '../data/sidenav.json';

import styles from './ReferenceTemplate.module.scss';

const ReferenceTemplate = ({ data }) => {
const loaded = useSdk();
const [isOpen, setIsOpen] = useState(false);
const { mdx } = data;
const { frontmatter } = mdx;
const { title, description, component } = frontmatter;

const componentData = window?.__NR1_SDK__?.default?.[component];

return (
<Layout>
<SEO title={title} description={description} />
Expand All @@ -28,6 +33,10 @@ const ReferenceTemplate = ({ data }) => {
/>
<main className={styles.content}>
<h1>{component}</h1>

{componentData && componentData.__docs__ && (
<ReactMarkdown source={componentData.__docs__.text} />
)}
</main>
</Container>
</Layout>
Expand Down

0 comments on commit 01b173f

Please sign in to comment.