Skip to content

Commit

Permalink
feat: add template for component docs
Browse files Browse the repository at this point in the history
  • Loading branch information
timglaser committed Jun 2, 2020
1 parent 14c1588 commit bc9c46e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/markdown-pages/components/button.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
path: '/components/button'
title: 'Button'
description: 'A button component!'
component: 'Button'
template: 'ReferenceTemplate'
---

32 changes: 28 additions & 4 deletions src/pages/reference.js → src/templates/ReferenceTemplate.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import React, { useState } from 'react';
import { graphql } from 'gatsby';
import PropTypes from 'prop-types';
import Container from '../components/Container';
import Layout from '../components/Layout';
import Sidebar from '../components/Sidebar';
import SEO from '../components/Seo';

import pages from '../data/sidenav.json';
import styles from './reference.module.scss';

const Reference = () => {
import styles from './ReferenceTemplate.module.scss';

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

return (
<Layout>
<SEO title="Reference" />
<SEO title={title} description={description} />
<Container className={styles.container}>
<Sidebar
className={styles.sidebar}
Expand All @@ -26,4 +32,22 @@ const Reference = () => {
);
};

export default Reference;
ReferenceTemplate.propTypes = {
data: PropTypes.object,
};

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

export default ReferenceTemplate;
File renamed without changes.

0 comments on commit bc9c46e

Please sign in to comment.