mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-07-01 06:02:10 +02:00
Merge pull request #633 from oceanprotocol/feature/read-the-docs
Fixes issue related to selected module when user clicks on sidebar
This commit is contained in:
commit
5bd24c5be3
|
@ -22,10 +22,10 @@ export default function MarkdownList({ pageContext }) {
|
|||
modules[key].push(node)
|
||||
})
|
||||
|
||||
const moduleKeys = Object.keys(modules).sort()
|
||||
|
||||
const [selectedSubSection, setSelectedSubSection] = useState(0)
|
||||
const [elem, setElem] = useState(
|
||||
modules[Object.keys(modules)[selectedSubSection]][0]
|
||||
)
|
||||
const [elem, setElem] = useState(modules[moduleKeys[selectedSubSection]][0])
|
||||
|
||||
const changePage = (subSectionIndex, node) => {
|
||||
setElem(node)
|
||||
|
@ -34,7 +34,7 @@ export default function MarkdownList({ pageContext }) {
|
|||
|
||||
const changeSubsection = (index) => {
|
||||
setSelectedSubSection(index)
|
||||
setElem(modules[Object.keys(modules)[index]][0])
|
||||
setElem(modules[moduleKeys[index]][0])
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -49,9 +49,7 @@ export default function MarkdownList({ pageContext }) {
|
|||
<main className={styles.wrapper}>
|
||||
<aside className={styles.sidebar}>
|
||||
<nav className={sidebarStyles.sidebar}>
|
||||
{Object.keys(modules)
|
||||
.sort()
|
||||
.map((ele, subSectionIndex) => {
|
||||
{moduleKeys.map((ele, subSectionIndex) => {
|
||||
return selectedSubSection === subSectionIndex ? (
|
||||
<div key={subSectionIndex}>
|
||||
<h4 className={sidebarStyles.groupTitle}>
|
||||
|
@ -71,9 +69,7 @@ export default function MarkdownList({ pageContext }) {
|
|||
: sidebarStyles.link
|
||||
}
|
||||
key={node.id}
|
||||
onClick={() =>
|
||||
changePage(subSectionIndex, node)
|
||||
}
|
||||
onClick={() => changePage(subSectionIndex, node)}
|
||||
>
|
||||
<a
|
||||
style={{
|
||||
|
|
Loading…
Reference in New Issue
Block a user