mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-01 15:55:34 +01:00
clean API paths, yay string manipulation
This commit is contained in:
parent
c6f995a7e4
commit
c9055b2c1e
@ -12,12 +12,27 @@ import SEO from '../components/Seo'
|
|||||||
import stylesDoc from './Doc.module.scss'
|
import stylesDoc from './Doc.module.scss'
|
||||||
import styles from './ApiSwagger.module.scss'
|
import styles from './ApiSwagger.module.scss'
|
||||||
|
|
||||||
|
const cleanKey = key => {
|
||||||
|
let keyCleaned = key
|
||||||
|
|
||||||
|
if (key.includes('aquarius')) {
|
||||||
|
keyCleaned = key.replace(/\/api\/v1\/aquarius/gi, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key.includes('brizo')) {
|
||||||
|
keyCleaned = key.replace(/\/api\/v1\/brizo/gi, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyCleaned
|
||||||
|
}
|
||||||
|
|
||||||
const toc = api => {
|
const toc = api => {
|
||||||
const items = Object.keys(api.paths).map(
|
const items = Object.keys(api.paths).map(
|
||||||
key =>
|
key => `<li key=${key}>
|
||||||
`<li key=${key}>
|
<a href="#${slugify(cleanKey(key))}"><code>${cleanKey(
|
||||||
<a href="#${slugify(key)}"><code>${key}</code></a>
|
key
|
||||||
</li>`
|
)}</code></a>
|
||||||
|
</li>`
|
||||||
)
|
)
|
||||||
|
|
||||||
return `<ul>${items}</ul>`
|
return `<ul>${items}</ul>`
|
||||||
@ -116,10 +131,10 @@ export default class ApiSwaggerTemplate extends Component {
|
|||||||
([key, value]) => (
|
([key, value]) => (
|
||||||
<div key={key}>
|
<div key={key}>
|
||||||
<h2
|
<h2
|
||||||
id={slugify(key)}
|
id={slugify(cleanKey(key))}
|
||||||
className={styles.pathName}
|
className={styles.pathName}
|
||||||
>
|
>
|
||||||
<code>{key}</code>
|
<code>{cleanKey(key)}</code>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
{Object.entries(value).map(
|
{Object.entries(value).map(
|
||||||
|
Loading…
Reference in New Issue
Block a user