1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

Show correct Aquarius rest enpoints (#699)

This commit is contained in:
Akshay 2021-08-16 11:19:09 +02:00 committed by GitHub
parent 5481cc81c2
commit 96ba9671cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 23 deletions

View File

@ -1,7 +1,6 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import slugify from 'slugify' import slugify from 'slugify'
import { cleanPathKey } from './utils'
import styles from './Paths.module.scss' import styles from './Paths.module.scss'
import stylesDoc from '../Doc.module.scss' import stylesDoc from '../Doc.module.scss'
@ -142,9 +141,9 @@ Method.propTypes = {
const Paths = ({ paths }) => const Paths = ({ paths }) =>
Object.entries(paths).map(([key, value]) => ( Object.entries(paths).map(([key, value]) => (
<div key={key} id={slugify(cleanPathKey(key))}> <div key={key} id={slugify(key)}>
<h2 className={stylesDoc.pathName}> <h2 className={stylesDoc.pathName}>
<code>{cleanPathKey(key)}</code> <code>{key}</code>
</h2> </h2>
{Object.entries(value).map(([key, value]) => ( {Object.entries(value).map(([key, value]) => (

View File

@ -9,29 +9,47 @@ import stylesSidebar from '../../components/Sidebar.module.scss'
const Toc = ({ data }) => { const Toc = ({ data }) => {
const Ids = [] const Ids = []
const items = Object.keys(data.paths).map((key) => { const itemsV1 = Object.keys(data.paths)
Ids.push(slugify(cleanPathKey(key))) .filter((key) => key.startsWith('/api/v1/aquarius'))
.map((key) => {
Ids.push(slugify(key))
return ( return (
<li key={key}> <li key={key}>
<Scroll <Scroll type="id" element={`${slugify(key)}`} offset={-20}>
type="id"
element={`${slugify(cleanPathKey(key))}`}
offset={-20}
>
<code>{cleanPathKey(key)}</code> <code>{cleanPathKey(key)}</code>
</Scroll> </Scroll>
</li> </li>
) )
}) })
const itemsOther = Object.keys(data.paths)
.filter((key) => !key.startsWith('/api/v1/aquarius'))
.map((key) => {
Ids.push(slugify(key))
return (
<li key={key}>
<Scroll type="id" element={`${slugify(key)}`} offset={-20}>
<code>{key}</code>
</Scroll>
</li>
)
})
return ( return (
<Scrollspy <Scrollspy
items={Ids} items={Ids}
currentClassName={stylesSidebar.scrollspyActive} currentClassName={stylesSidebar.scrollspyActive}
offset={-100} offset={-100}
> >
{items} <code>/api/v1/aquarius</code>
<ul>{itemsV1}</ul>
{itemsOther.length ? (
<>
<code>Other REST endpoints</code>
<ul>{itemsOther}</ul>
</>
) : null}
</Scrollspy> </Scrollspy>
) )
} }

View File

@ -4,10 +4,5 @@ export const cleanPathKey = (key) => {
if (key.includes('aquarius')) { if (key.includes('aquarius')) {
keyCleaned = key.replace(/\/api\/v1\/aquarius/gi, '') keyCleaned = key.replace(/\/api\/v1\/aquarius/gi, '')
} }
if (key.includes('brizo')) {
keyCleaned = key.replace(/\/api\/v1\/brizo/gi, '')
}
return keyCleaned return keyCleaned
} }