mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
reduced TOC, fix scrollspy
This commit is contained in:
parent
253cb14085
commit
f4fd41ef38
@ -1,10 +1,10 @@
|
|||||||
import React, { PureComponent } from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import slugify from 'slugify'
|
import slugify from 'slugify'
|
||||||
// import Scrollspy from 'react-scrollspy'
|
import Scrollspy from 'react-scrollspy'
|
||||||
import Scroll from '../../components/Scroll'
|
import Scroll from '../../components/Scroll'
|
||||||
import { cleanPaths } from './utils'
|
import { cleanPaths } from './utils'
|
||||||
// import stylesSidebar from '../../components/Sidebar.module.scss'
|
import stylesSidebar from '../../components/Sidebar.module.scss'
|
||||||
|
|
||||||
export default class Toc extends PureComponent {
|
export default class Toc extends PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -36,24 +36,27 @@ export default class Toc extends PureComponent {
|
|||||||
const slug = slugify(cleanedPath, {
|
const slug = slugify(cleanedPath, {
|
||||||
remove: /[*+~.()'"/!:@]/g
|
remove: /[*+~.()'"/!:@]/g
|
||||||
})
|
})
|
||||||
|
let entity = cleanedPath.split('/')
|
||||||
|
entity = entity.pop()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={path}>
|
<li key={path}>
|
||||||
<Scroll type="id" element={slug} offset={-20}>
|
<Scroll type="id" element={`${slug}`} offset={-20}>
|
||||||
<code>{cleanedPath}</code>
|
<code>{entity}</code>
|
||||||
</Scroll>
|
</Scroll>
|
||||||
{/* <Scrollspy
|
|
||||||
items={this.state.subIds}
|
|
||||||
currentClassName={stylesSidebar.scrollspyActive}
|
|
||||||
offset={-30}
|
|
||||||
>
|
|
||||||
{cleanedPath}
|
|
||||||
</Scrollspy> */}
|
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <ul>{this.items}</ul>
|
return (
|
||||||
|
<Scrollspy
|
||||||
|
items={this.state.subIds}
|
||||||
|
currentClassName={stylesSidebar.scrollspyActive}
|
||||||
|
offset={-30}
|
||||||
|
>
|
||||||
|
{this.items}
|
||||||
|
</Scrollspy>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user