mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +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 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 items = Object.keys(api.paths).map(
|
||||
key =>
|
||||
`<li key=${key}>
|
||||
<a href="#${slugify(key)}"><code>${key}</code></a>
|
||||
</li>`
|
||||
key => `<li key=${key}>
|
||||
<a href="#${slugify(cleanKey(key))}"><code>${cleanKey(
|
||||
key
|
||||
)}</code></a>
|
||||
</li>`
|
||||
)
|
||||
|
||||
return `<ul>${items}</ul>`
|
||||
@ -116,10 +131,10 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
([key, value]) => (
|
||||
<div key={key}>
|
||||
<h2
|
||||
id={slugify(key)}
|
||||
id={slugify(cleanKey(key))}
|
||||
className={styles.pathName}
|
||||
>
|
||||
<code>{key}</code>
|
||||
<code>{cleanKey(key)}</code>
|
||||
</h2>
|
||||
|
||||
{Object.entries(value).map(
|
||||
|
Loading…
Reference in New Issue
Block a user