mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
deal with json files directly, no other way right now
This commit is contained in:
parent
0fa9eeaf96
commit
efbac73ee9
@ -9,22 +9,6 @@ if (!process.env.GITHUB_TOKEN) {
|
||||
|
||||
const config = require('./config.js')
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const fromJson = filePath => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(filePath, 'utf8', (err, data) => { // eslint-disable-line
|
||||
if (err) {
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
|
||||
resolve(data)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
siteMetadata: {
|
||||
// spread all of our config values here
|
||||
@ -122,27 +106,6 @@ module.exports = {
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
resolve: 'gatsby-source-openapi-aggregate',
|
||||
options: {
|
||||
specs: [
|
||||
{
|
||||
name: 'aquarius',
|
||||
resolve: () =>
|
||||
fromJson(
|
||||
path.resolve(__dirname, './data/aquarius.json')
|
||||
)
|
||||
},
|
||||
{
|
||||
name: 'brizo',
|
||||
resolve: () =>
|
||||
fromJson(
|
||||
path.resolve(__dirname, './data/brizo.json')
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
'gatsby-transformer-yaml',
|
||||
{
|
||||
resolve: 'gatsby-plugin-sass',
|
||||
|
@ -135,7 +135,7 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
component: apiSwaggerTemplate,
|
||||
context: {
|
||||
slug: aquariusSlug,
|
||||
json: aquariusSpecs
|
||||
api: aquariusSpecs
|
||||
}
|
||||
})
|
||||
|
||||
@ -147,7 +147,7 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
component: apiSwaggerTemplate,
|
||||
context: {
|
||||
slug: brizoSlug,
|
||||
json: brizoSpecs
|
||||
api: brizoSpecs
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -47,7 +47,6 @@
|
||||
"gatsby-remark-smartypants": "^2.0.6",
|
||||
"gatsby-source-filesystem": "^2.0.9",
|
||||
"gatsby-source-graphql": "^2.0.6",
|
||||
"gatsby-source-openapi-aggregate": "^0.1.8",
|
||||
"gatsby-transformer-remark": "^2.1.12",
|
||||
"gatsby-transformer-sharp": "^2.1.8",
|
||||
"gatsby-transformer-yaml": "^2.1.5",
|
||||
|
@ -20,8 +20,8 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
|
||||
render() {
|
||||
const { location, data, pageContext } = this.props
|
||||
const sections = this.props.data.allSectionsYaml.edges
|
||||
const { title, description } = pageContext.json.info
|
||||
const sections = data.allSectionsYaml.edges
|
||||
const { title, description } = pageContext.api.info
|
||||
|
||||
// output section title as defined in sections.yml
|
||||
const sectionTitle = sections.map(({ node }) => {
|
||||
@ -31,8 +31,6 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
}
|
||||
})
|
||||
|
||||
console.log(data)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
@ -61,7 +59,7 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
<article className={stylesDoc.main}>
|
||||
<DocHeader title={title} />
|
||||
|
||||
{Object.keys(pageContext.json.paths).map(
|
||||
{Object.keys(pageContext.api.paths).map(
|
||||
path => (
|
||||
<div key={path} className={styles.path}>
|
||||
<h2>{path}</h2>
|
||||
@ -79,13 +77,7 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
}
|
||||
|
||||
export const pageQuery = graphql`
|
||||
query($slug: String!) {
|
||||
markdownRemark(fields: { slug: { eq: $slug } }) {
|
||||
id
|
||||
tableOfContents
|
||||
html
|
||||
}
|
||||
|
||||
query {
|
||||
allSectionsYaml {
|
||||
edges {
|
||||
node {
|
||||
|
Loading…
Reference in New Issue
Block a user