Skip to content

Commit

Permalink
refactor: Move usage into useComponentDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 4, 2020
1 parent 7a4a20a commit 4397c34
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/hooks/useComponentDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const useComponentDoc = (componentName) => {
return {
description: componentDocs?.text,
examples: componentDocs?.tags.examples ?? [],
usage: `import { ${componentName} } from 'nr1'`,
methods: Object.getOwnPropertyNames(component)
.filter(
(member) =>
Expand Down
3 changes: 2 additions & 1 deletion src/templates/ReferenceTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ReferenceTemplate = ({ data }) => {
examples,
description: componentDescription,
methods,
usage,
} = useComponentDoc(component);

return (
Expand All @@ -48,7 +49,7 @@ const ReferenceTemplate = ({ data }) => {
</section>
<section className={styles.section}>
<h2>Usage</h2>
<InlineCodeSnippet language="js">{`import { ${component} } from 'nr1'`}</InlineCodeSnippet>
<InlineCodeSnippet language="js">{usage}</InlineCodeSnippet>
</section>
{examples.length > 0 && (
<section className={styles.section}>
Expand Down

0 comments on commit 4397c34

Please sign in to comment.