diff --git a/content/concepts/architecture.md b/content/concepts/architecture.md deleted file mode 100644 index 80db458b..00000000 --- a/content/concepts/architecture.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Architecture -description: The architecture of Ocean Protocol with all its components and how they work together. ---- - -See the page about the [Ocean network components](/concepts/components/). - -See the (somewhat-dated) diagram on the page https://github.com/oceanprotocol/dev-ocean/blob/master/doc/architecture.md - -![Ocean Protocol Components](images/components.png 'Ocean Protocol Components') diff --git a/data/sidebars/concepts.yml b/data/sidebars/concepts.yml index d1452801..d3b8202f 100644 --- a/data/sidebars/concepts.yml +++ b/data/sidebars/concepts.yml @@ -6,13 +6,13 @@ link: /concepts/terminology/ - title: Software Components link: /concepts/components/ - - title: Architecture - link: /concepts/architecture/ -- group: Details +- group: Architecture items: - - title: Coming Soon - link: / + - title: Overview + link: /concepts/architecture/ + - title: Squid + link: /concepts/squid/ - group: Contribute items: diff --git a/gatsby-node.js b/gatsby-node.js index 8930d691..8180601d 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -22,8 +22,47 @@ exports.onCreateNode = ({ node, getNode, actions }) => { value: section }) } + + // // console.log(node) + + // // if (node.internal.owner === 'gatsby-source-graphql') { + // // console.log(node) + // // } } +// exports.sourceNodes = ( +// { actions, createNodeId, createContentDigest }, +// configOptions +// ) => { +// const { createNode } = actions + +// // Gatsby adds a configOption that's not needed for this plugin, delete it +// delete configOptions.plugins + +// createNode({ +// // Data for the node. +// field1: `a string`, +// field2: 10, +// field3: true, +// ...arbitraryOtherData, + +// // Required fields. +// id: `a-node-id`, +// parent: `the-id-of-the-parent-node`, // or null if it's a source node without a parent +// children: [], +// internal: { +// type: `CoolServiceMarkdownField`, +// contentDigest: crypto +// .createHash(`md5`) +// .update(JSON.stringify(fieldData)) +// .digest(`hex`), +// mediaType: `text/markdown`, // optional +// content: JSON.stringify(fieldData), // optional +// description: `Cool Service: "Title of entry"` // optional +// } +// }) +// } + exports.createPages = ({ graphql, actions }) => { const { createPage } = actions @@ -44,6 +83,28 @@ exports.createPages = ({ graphql, actions }) => { } } } + + github { + repository( + owner: "oceanprotocol" + name: "dev-ocean" + ) { + root: object( + expression: "master:doc/architecture.md" + ) { + ... on GitHub_Blob { + text + } + } + squid: object( + expression: "master:doc/architecture/squid.md" + ) { + ... on GitHub_Blob { + text + } + } + } + } } ` ).then(result => { @@ -53,8 +114,8 @@ exports.createPages = ({ graphql, actions }) => { reject(result.errors) } - const posts = result.data.allMarkdownRemark.edges const docTemplate = path.resolve('./src/templates/Doc.jsx') + const posts = result.data.allMarkdownRemark.edges // Create Doc pages posts.forEach(post => { @@ -68,6 +129,35 @@ exports.createPages = ({ graphql, actions }) => { }) }) + // Create Architecture section from dev-ocean contents + const docRepoTemplate = path.resolve( + './src/templates/DocRepo.jsx' + ) + + createPage({ + path: '/concepts/architecture/', + component: docRepoTemplate, + context: { + slug: '/concepts/architecture/', + section: 'concepts', + title: 'Architecture', + description: 'Hello description', + content: `${result.data.github.repository.root.text}` + } + }) + + createPage({ + path: '/concepts/squid/', + component: docRepoTemplate, + context: { + slug: '/concepts/squid/', + section: 'concepts', + title: 'Squid', + description: 'Hello description', + content: `${result.data.github.repository.squid.text}` + } + }) + resolve() }) ) diff --git a/src/components/DocContent.jsx b/src/components/DocContent.jsx index e639bc02..14ff3230 100644 --- a/src/components/DocContent.jsx +++ b/src/components/DocContent.jsx @@ -9,18 +9,24 @@ const renderAst = new RehypeReact({ components: { repo: Repository } }).Compiler -const DocContent = ({ html, htmlAst }) => - html ? ( +const DocContent = ({ html, htmlAst, github }) => { + if (github) { + return
{html}
+ } + + return html ? (
{renderAst(htmlAst)}
) : (
This is a placeholder for now. Help creating it.
) +} DocContent.propTypes = { html: PropTypes.string, - htmlAst: PropTypes.object + htmlAst: PropTypes.object, + github: PropTypes.bool } export default DocContent diff --git a/src/templates/Doc.jsx b/src/templates/Doc.jsx index 6a4658e2..0d8d218e 100644 --- a/src/templates/Doc.jsx +++ b/src/templates/Doc.jsx @@ -14,15 +14,17 @@ import styles from './Doc.module.scss' export default class DocTemplate extends Component { static propTypes = { data: PropTypes.object.isRequired, - location: PropTypes.object.isRequired + location: PropTypes.object.isRequired, + pageContext: PropTypes.object } render() { const { location } = this.props const post = this.props.data.markdownRemark const sections = this.props.data.allSectionsYaml.edges - const { section } = post.fields - const { title, description } = post.frontmatter + const { section } = post.fields ? post.fields : this.props.pageContext + const { title, description } = + post.frontmatter || this.props.pageContext // output section title as defined in sections.yml const sectionTitle = sections.map(({ node }) => { diff --git a/src/templates/DocRepo.jsx b/src/templates/DocRepo.jsx new file mode 100644 index 00000000..981c402e --- /dev/null +++ b/src/templates/DocRepo.jsx @@ -0,0 +1,89 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import { graphql } from 'gatsby' +import Helmet from 'react-helmet' +import Layout from '../components/Layout' +import Content from '../components/Content' +import HeaderSection from '../components/HeaderSection' +import Sidebar from '../components/Sidebar' +import DocContent from '../components/DocContent' +import DocHeader from '../components/DocHeader' +import styles from './Doc.module.scss' + +export default class DocRepoTemplate extends Component { + static propTypes = { + data: PropTypes.object.isRequired, + location: PropTypes.object.isRequired, + pageContext: PropTypes.object + } + + render() { + const { location } = this.props + const sections = this.props.data.allSectionsYaml.edges + const { section } = this.props.pageContext + const { title, description, content } = this.props.pageContext + + // output section title as defined in sections.yml + const sectionTitle = sections.map(({ node }) => { + // compare section against section title from sections.yml + if (node.title.toLowerCase().includes(section)) { + return node.title + } + }) + + return ( + <> + + {title} + + + + + + + + {section ? ( +
+ +
+ + +
+
+ ) : ( +
+ + +
+ )} +
+
+ + ) + } +} + +export const pageQuery = graphql` + query { + allSectionsYaml { + edges { + node { + title + description + link + } + } + } + } +`