From c9055b2c1e58dac941f79aad69d963f2cd22d02b Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 29 Nov 2018 11:09:02 +0100 Subject: [PATCH] clean API paths, yay string manipulation --- src/templates/ApiSwagger.jsx | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/templates/ApiSwagger.jsx b/src/templates/ApiSwagger.jsx index 13694b67..f6e4ad40 100644 --- a/src/templates/ApiSwagger.jsx +++ b/src/templates/ApiSwagger.jsx @@ -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 => - `
  • - ${key} -
  • ` + key => `
  • + ${cleanKey( + key + )} +
  • ` ) return `` @@ -116,10 +131,10 @@ export default class ApiSwaggerTemplate extends Component { ([key, value]) => (

    - {key} + {cleanKey(key)}

    {Object.entries(value).map(