From a53c227acc477e72859432b5367f5b3a0d6d4c2d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 12 Nov 2018 18:56:59 +0100 Subject: [PATCH 01/21] attach readme contents to all repos --- content/concepts/components.md | 2 +- content/test.md | 13 ++++++- package.json | 4 ++- src/components/Repositories/Repository.jsx | 35 +++++++++++++++++-- .../Repositories/Repository.module.scss | 23 ++++++++++++ 5 files changed, 71 insertions(+), 6 deletions(-) diff --git a/content/concepts/components.md b/content/concepts/components.md index 39d649d2..67dfcaa6 100644 --- a/content/concepts/components.md +++ b/content/concepts/components.md @@ -11,7 +11,7 @@ Every marketplace must run an instance of Aquarius. Aquarius provides an API to an off-chain database ("OceanDB") to store and manage metadata about data assets: the assets listed in that marketplace. The off-chain database might be MongoDB, Elasticsearch or BigchainDB. - + ## Brizo diff --git a/content/test.md b/content/test.md index abad41e0..331b36a4 100644 --- a/content/test.md +++ b/content/test.md @@ -359,10 +359,21 @@ Note that the component name in Markdown needs to be always in lowercase, and ha The `Repository` component fetching and displaying information about a GitHub repo. Component can be used in Markdown as ``, it requires a `name` to be passed: -```HTML +```html ``` Resulting in: + +You can also pass `readme="true"` and the readme contents of the repo will be rendered: + +```html + +``` + +Resulting in: + + + diff --git a/package.json b/package.json index 6149bda7..88b2e806 100755 --- a/package.json +++ b/package.json @@ -54,7 +54,9 @@ "react": "^16.6.1", "react-dom": "^16.6.1", "react-helmet": "^5.2.0", - "rehype-react": "^3.0.3" + "rehype-react": "^3.0.3", + "remark": "^10.0.0", + "remark-react": "^4.0.3" }, "devDependencies": { "@svgr/webpack": "^4.0.2", diff --git a/src/components/Repositories/Repository.jsx b/src/components/Repositories/Repository.jsx index ea8bf6aa..f3f6f7e2 100644 --- a/src/components/Repositories/Repository.jsx +++ b/src/components/Repositories/Repository.jsx @@ -1,6 +1,8 @@ import React from 'react' import PropTypes from 'prop-types' import { StaticQuery, graphql } from 'gatsby' +import remark from 'remark' +import remarkReact from 'remark-react' import { ReactComponent as Star } from '../../images/star.svg' import { ReactComponent as Forks } from '../../images/forks.svg' import styles from './Repository.module.scss' @@ -31,6 +33,12 @@ const queryGithub = graphql` } } } + object(expression: "develop:README.md") { + id + ... on GitHub_Blob { + text + } + } } } } @@ -98,7 +106,7 @@ Numbers.propTypes = { url: PropTypes.string.isRequired } -const Repository = ({ name, links }) => ( +const Repository = ({ name, links, readme }) => ( { @@ -119,7 +127,18 @@ const Repository = ({ name, links }) => ( // e.g. when private repos are referenced in repositories.yml if (repo === undefined) return null - const { url, description, forkCount, stargazers, releases } = repo + const { + url, + description, + forkCount, + stargazers, + releases, + object + } = repo + + const readmeHtml = remark() + .use(remarkReact) + .processSync(object.text).contents return (
@@ -135,6 +154,15 @@ const Repository = ({ name, links }) => ( url={url} /> + + {readme && ( + + )}
) }} @@ -143,7 +171,8 @@ const Repository = ({ name, links }) => ( Repository.propTypes = { name: PropTypes.string.isRequired, - links: PropTypes.array + links: PropTypes.array, + readme: PropTypes.bool } export default Repository diff --git a/src/components/Repositories/Repository.module.scss b/src/components/Repositories/Repository.module.scss index 28380155..9049bb93 100644 --- a/src/components/Repositories/Repository.module.scss +++ b/src/components/Repositories/Repository.module.scss @@ -87,3 +87,26 @@ margin-bottom: -.1rem; } } + +.repositoryReadme { + margin-top: $spacer; + + h1, + h2 { + font-size: $font-size-large; + } + + h3, + h4 { + font-size: $font-size-base; + } +} + +.repositoryReadmeTitle { + font-size: $font-size-small !important; // stylelint-disable-line + margin: 0; + color: $brand-grey-light; + margin-bottom: $spacer / 2; + padding-bottom: $spacer / 3; + border-bottom: 1px solid $brand-grey-lighter; +} From f5bc1ae68a384085e977aea6f5ff47b4ac568a6e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 12 Nov 2018 19:29:47 +0100 Subject: [PATCH 02/21] build fixes --- src/components/Repositories/Repository.jsx | 10 ++++++---- src/components/Repositories/Repository.module.scss | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/Repositories/Repository.jsx b/src/components/Repositories/Repository.jsx index f3f6f7e2..e19525ce 100644 --- a/src/components/Repositories/Repository.jsx +++ b/src/components/Repositories/Repository.jsx @@ -136,9 +136,11 @@ const Repository = ({ name, links, readme }) => ( object } = repo - const readmeHtml = remark() - .use(remarkReact) - .processSync(object.text).contents + const readmeHtml = object + ? remark() + .use(remarkReact) + .processSync(object.text).contents + : null return (
@@ -155,7 +157,7 @@ const Repository = ({ name, links, readme }) => ( /> - {readme && ( + {readme && object && (