mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-02 00:05:35 +01:00
scrollspy for sub items
This commit is contained in:
parent
5a0f7eacc2
commit
6c90d37672
@ -173,9 +173,7 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
|
||||
<div className={styles.deprecation}>
|
||||
<strong>Deprecated</strong>: use{' '}
|
||||
<code>
|
||||
<a href={`#${deprecatedSlug}`}>
|
||||
{deprecatedUse}
|
||||
</a>
|
||||
<a href={`#${deprecatedSlug}`}>{deprecatedUse}</a>
|
||||
</code>{' '}
|
||||
instead
|
||||
</div>
|
||||
@ -224,16 +222,14 @@ const Entities = ({ entities, sourceUrl }) =>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{children
|
||||
.filter(filterByKindOfProperty)
|
||||
.map(property => (
|
||||
<PropertyWrapper
|
||||
key={`${name}/${property.id}`}
|
||||
property={property}
|
||||
sourceUrl={sourceUrl}
|
||||
parentAnchor={slugify(name)}
|
||||
/>
|
||||
))}
|
||||
{children.filter(filterByKindOfProperty).map(property => (
|
||||
<PropertyWrapper
|
||||
key={`${name}/${property.id}`}
|
||||
property={property}
|
||||
sourceUrl={sourceUrl}
|
||||
parentAnchor={slugify(name)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
))
|
||||
|
||||
|
@ -6,55 +6,44 @@ import stylesSidebar from '../../components/Sidebar.module.scss'
|
||||
|
||||
const Toc = ({ data }) => {
|
||||
const subItems = (children, parentName) =>
|
||||
children.map(({ name }) => {
|
||||
return (
|
||||
<li key={name}>
|
||||
<a href={`#${parentName}-${slugify(name)}`}>
|
||||
<code>{name}</code>
|
||||
</a>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
children.map(({ name }) => (
|
||||
<li key={name}>
|
||||
<a href={`#${parentName}-${slugify(name)}`}>
|
||||
<code>{name}</code>
|
||||
</a>
|
||||
</li>
|
||||
))
|
||||
|
||||
const items = data.map(({ name, children }) => {
|
||||
// let subIds = []
|
||||
let subIds = []
|
||||
const parentName = name
|
||||
|
||||
// subIds.push(
|
||||
// data.map(({ name, children }) => {
|
||||
// const parentName = name
|
||||
// let childId
|
||||
|
||||
// children.map(({ name }) => {
|
||||
// childId = `${parentName}-${slugify(name)}`
|
||||
// })
|
||||
|
||||
// return childId
|
||||
// })
|
||||
// )
|
||||
|
||||
// console.log(subIds)
|
||||
subIds.push(
|
||||
children.map(({ name }) => {
|
||||
return `${parentName}-${slugify(name)}`
|
||||
})
|
||||
)
|
||||
|
||||
return (
|
||||
<li key={name}>
|
||||
<a href={`#${slugify(name)}`}>
|
||||
<code>{name}</code>
|
||||
</a>
|
||||
<ul>{subItems(children, name)}</ul>
|
||||
<Scrollspy
|
||||
items={subIds[0]}
|
||||
currentClassName={stylesSidebar.scrollspyActive}
|
||||
offset={-200}
|
||||
>
|
||||
{subItems(children, name)}
|
||||
</Scrollspy>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
|
||||
let Ids = []
|
||||
Ids.push(data.map(({ name }) => slugify(name)))
|
||||
// let Ids = []
|
||||
// Ids.push(data.map(({ name }) => slugify(name)))
|
||||
|
||||
return (
|
||||
<Scrollspy
|
||||
items={Ids[0]}
|
||||
currentClassName={stylesSidebar.scrollspyActive}
|
||||
>
|
||||
{items}
|
||||
</Scrollspy>
|
||||
)
|
||||
return <ul>{items}</ul>
|
||||
}
|
||||
|
||||
Toc.propTypes = {
|
||||
|
Loading…
Reference in New Issue
Block a user