diff --git a/src/templates/Swagger/Paths.jsx b/src/templates/Swagger/Paths.jsx index c5e2615c..b4583de5 100644 --- a/src/templates/Swagger/Paths.jsx +++ b/src/templates/Swagger/Paths.jsx @@ -137,8 +137,8 @@ Method.propTypes = { const Paths = ({ paths }) => Object.entries(paths).map(([key, value]) => ( -
-

+
+

{cleanPathKey(key)}

diff --git a/src/templates/Swagger/Toc.jsx b/src/templates/Swagger/Toc.jsx index 42c4b68b..ad47d59a 100644 --- a/src/templates/Swagger/Toc.jsx +++ b/src/templates/Swagger/Toc.jsx @@ -1,18 +1,34 @@ import React from 'react' import PropTypes from 'prop-types' import slugify from 'slugify' +import Scrollspy from 'react-scrollspy' import { cleanPathKey } from './utils' +import stylesSidebar from '../../components/Sidebar.module.scss' const Toc = ({ data }) => { - const items = Object.keys(data.paths).map(key => ( -
  • - - {cleanPathKey(key)} - -
  • - )) + let Ids = [] - return
      {items}
    + const items = Object.keys(data.paths).map(key => { + Ids.push(slugify(cleanPathKey(key))) + + return ( +
  • + + {cleanPathKey(key)} + +
  • + ) + }) + + return ( + + {items} + + ) } Toc.propTypes = { diff --git a/src/templates/Typedoc/Entities.jsx b/src/templates/Typedoc/Entities.jsx index 451dc206..0a5b2799 100644 --- a/src/templates/Typedoc/Entities.jsx +++ b/src/templates/Typedoc/Entities.jsx @@ -211,8 +211,8 @@ PropertyWrapper.propTypes = { const Entities = ({ entities, sourceUrl }) => entities.map(({ name, comment, children }) => ( -
    -

    +
    +

    {name}

    diff --git a/src/templates/Typedoc/Toc.jsx b/src/templates/Typedoc/Toc.jsx index 43f0d25f..6fef43b2 100644 --- a/src/templates/Typedoc/Toc.jsx +++ b/src/templates/Typedoc/Toc.jsx @@ -1,12 +1,17 @@ -import React from 'react' +import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import slugify from 'slugify' import Scrollspy from 'react-scrollspy' +import { filterByKindOfProperty } from './utils' import stylesSidebar from '../../components/Sidebar.module.scss' -const Toc = ({ data }) => { - const subItems = (children, parentName) => - children.map(({ name }) => ( +export default class Toc extends PureComponent { + static propTypes = { + data: PropTypes.array + } + + subItems = (children, parentName) => + children.filter(filterByKindOfProperty).map(({ name }) => (
  • {name} @@ -14,12 +19,12 @@ const Toc = ({ data }) => {
  • )) - const items = data.map(({ name, children }) => { + items = this.props.data.map(({ name, children }) => { let subIds = [] const parentName = name subIds.push( - children.map(({ name }) => { + children.filter(filterByKindOfProperty).map(({ name }) => { return `${parentName}-${slugify(name)}` }) ) @@ -32,22 +37,26 @@ const Toc = ({ data }) => { - {subItems(children, name)} + {this.subItems(children, name)} ) }) - // let Ids = [] - // Ids.push(data.map(({ name }) => slugify(name))) + render() { + let Ids = [] + Ids.push(this.props.data.map(({ name }) => name)) - return
      {items}
    + return ( + + {this.items} + + ) + } } - -Toc.propTypes = { - data: PropTypes.array -} - -export default Toc diff --git a/src/templates/Typedoc/utils.js b/src/templates/Typedoc/utils.js index bd5adfd1..582e4824 100644 --- a/src/templates/Typedoc/utils.js +++ b/src/templates/Typedoc/utils.js @@ -21,7 +21,7 @@ export const cleanTypedocData = (data, useClasses) => { // more kinds: 'Property', 'Class' const showKindOfProperty = { Method: true, - Property: {onlyPublic: true}, + Property: { onlyPublic: true } } export const filterByKindOfProperty = ({ kindString, flags }) => { const config = showKindOfProperty[kindString]