+
{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
+ 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]