Skip to content

Commit fa34d82

Browse files
authored
Merge pull request #223 from heitorlessa/docs/add-source-code-link
docs: add source code link in nav bar
2 parents 704eba7 + e972257 commit fa34d82

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: docs/src/gatsby-theme-apollo-docs/components/page-content.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export default function PageContent(props) {
181181

182182
const githubUrl = props.githubUrl.replace("tree/", "blob/")
183183
.replace("/content/", "/docs/content/")
184+
const sourceUrl = /.+?(?=tree)/.exec(props.githubUrl)
184185

185186
const editLink = githubUrl && (
186187
<AsideLink href={githubUrl}>
@@ -210,6 +211,9 @@ export default function PageContent(props) {
210211
/>
211212
)}
212213
{editLink}
214+
<AsideLink href={sourceUrl}>
215+
<IconGithub /> Source code
216+
</AsideLink>
213217
</Aside>
214218
</Wrapper>
215219
);
@@ -218,11 +222,11 @@ export default function PageContent(props) {
218222
PageContent.propTypes = {
219223
children: PropTypes.node.isRequired,
220224
pathname: PropTypes.string.isRequired,
221-
githubUrl: PropTypes.string,
225+
githubUrl: PropTypes.string.isRequired,
222226
pages: PropTypes.array.isRequired,
223227
hash: PropTypes.string.isRequired,
224228
title: PropTypes.string.isRequired,
225-
graphManagerUrl: PropTypes.string.isRequired,
229+
graphManagerUrl: PropTypes.string,
226230
headings: PropTypes.array.isRequired,
227231
spectrumUrl: PropTypes.string
228232
};

0 commit comments

Comments
 (0)