Skip to content

Commit

Permalink
feat: create a related content component
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jul 29, 2020
1 parent c7a9089 commit 1d183b9
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/components/RelatedContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, { useContext } from 'react';
import { css } from '@emotion/core';
import { graphql, useStaticQuery } from 'gatsby';
import { Button, ExternalLink, Icon } from '@newrelic/gatsby-theme-newrelic';
import { PageContext } from './PageContext';

const RelatedContent = ({ className }) => {
const { site } = useStaticQuery(graphql`
query {
site {
siteMetadata {
repository
}
layout {
contentPadding
}
}
}
`);
const { fileRelativePath } = useContext(PageContext);

const {
layout,
siteMetadata: { repository },
} = site;

return (
<aside
className={className}
css={css`
padding: 0 ${layout.contentPadding};
`}
>
<h4>Contribute</h4>
<Button
as={ExternalLink}
href={`${repository}/issues/new/choose`}
css={css`
margin-right: 0.5rem;
`}
variant={Button.VARIANT.PRIMARY}
size={Button.SIZE.SMALL}
>
<Icon
name={Icon.TYPE.GITHUB}
css={css`
margin-right: 0.5rem;
`}
/>
File an issue
</Button>
<Button
as={ExternalLink}
href={`${repository}/tree/main/${fileRelativePath}`}
variant={Button.VARIANT.PLAIN}
size={Button.SIZE.SMALL}
>
<Icon
name={Icon.TYPE.EDIT}
css={css`
margin-right: 0.5rem;
`}
/>
Edit this page
</Button>
</aside>
);
};

export default RelatedContent;

0 comments on commit 1d183b9

Please sign in to comment.