import cx from 'classnames'
import { useState } from 'react'
import { ChevronDownIcon } from '@primer/octicons-react'
import { ProductTreeNode, useMainContext } from 'components/context/MainContext'
import { Link } from 'components/Link'
const maxArticles = 10
export const ProductArticlesList = () => {
const { currentProductTree } = useMainContext()
if (!currentProductTree) {
return null
}
return (
{currentProductTree.childPages.map((treeNode, i) => {
if (treeNode.page.documentType === 'article') {
return null
}
return
})}
)
}
const ProductTreeNodeList = ({ treeNode }: { treeNode: ProductTreeNode }) => {
const [isShowingMore, setIsShowingMore] = useState(false)
return (
{treeNode.renderedFullTitle}
{treeNode.childPages.map((childNode, index) => {
if (treeNode.childPages[0].page.documentType === 'mapTopic' && childNode.page.hidden) {
return null
}
return (
- = maxArticles ? 'd-none' : null)}
>
{childNode.page.title}
{childNode.page.documentType === 'mapTopic' ? (
• {childNode.childPages.length} articles
) : null}
)
})}
{!isShowingMore && treeNode.childPages.length > maxArticles && (
)}
)
}