From 2b570b47260694d399bdc082a995329355dce874 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 12 Nov 2018 20:21:12 +0100 Subject: [PATCH] embed any file's content from GitHub --- content/test.md | 11 +++++++++++ gatsby-config.js | 11 +++++++++++ package.json | 1 + src/components/HeaderSection.jsx | 2 +- src/components/Repositories/Repository.jsx | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/content/test.md b/content/test.md index 331b36a4..1a8d7c12 100644 --- a/content/test.md +++ b/content/test.md @@ -377,3 +377,14 @@ Resulting in: +### Embedding File Contents from GitHub + +You can embed any file contents like so, note that the language needs to be defined manually to get proper syntax highlighting: + +```text +GITHUB-EMBED https://github.com/oceanprotocol/squid-js/blob/develop/src/keeper/Web3Provider.ts js GITHUB-EMBED +``` + +Resulting in: + +GITHUB-EMBED https://github.com/oceanprotocol/squid-js/blob/develop/src/keeper/Web3Provider.ts js GITHUB-EMBED diff --git a/gatsby-config.js b/gatsby-config.js index a45c92d8..63a3beee 100755 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -73,6 +73,17 @@ module.exports = { showCaptions: true } }, + { + resolve: 'gatsby-remark-github', + options: { + marker: 'GITHUB-EMBED', + insertEllipsisComments: true, + ellipsisPhrase: '...', + useCache: true, + cacheKey: 'gatsby-remark-github-v1', + token: process.env.GITHUB_TOKEN + } + }, 'gatsby-remark-smartypants', 'gatsby-remark-embed-video', 'gatsby-remark-responsive-iframe', diff --git a/package.json b/package.json index 88b2e806..c248ad90 100755 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "gatsby-remark-component": "^1.1.3", "gatsby-remark-copy-linked-files": "^2.0.6", "gatsby-remark-embed-video": "^1.4.0", + "gatsby-remark-github": "^1.0.1", "gatsby-remark-images": "^2.0.6", "gatsby-remark-prismjs": "^3.0.3", "gatsby-remark-responsive-iframe": "^2.0.6", diff --git a/src/components/HeaderSection.jsx b/src/components/HeaderSection.jsx index 74a244e2..a9971d6c 100644 --- a/src/components/HeaderSection.jsx +++ b/src/components/HeaderSection.jsx @@ -18,7 +18,7 @@ const HeaderSection = ({ title }) => ( ) HeaderSection.propTypes = { - title: PropTypes.array + title: PropTypes.PropTypes.oneOfType([PropTypes.array, PropTypes.string]) } export default HeaderSection diff --git a/src/components/Repositories/Repository.jsx b/src/components/Repositories/Repository.jsx index e19525ce..74dfb69b 100644 --- a/src/components/Repositories/Repository.jsx +++ b/src/components/Repositories/Repository.jsx @@ -174,7 +174,7 @@ const Repository = ({ name, links, readme }) => ( Repository.propTypes = { name: PropTypes.string.isRequired, links: PropTypes.array, - readme: PropTypes.bool + readme: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]) } export default Repository