|
| 1 | +import React, {memo} from 'react'; |
| 2 | +import clsx from 'clsx'; |
| 3 | +import {translate} from '@docusaurus/Translate'; |
| 4 | +import Link from '@docusaurus/Link'; |
| 5 | + |
| 6 | +import { |
| 7 | + useVisibleBlogSidebarItems, |
| 8 | + BlogSidebarItemList, |
| 9 | +} from '@docusaurus/plugin-content-blog/client'; |
| 10 | +import BlogSidebarContent from '@theme/BlogSidebar/Content'; |
| 11 | +import styles from './styles.module.css'; |
| 12 | +const ListComponent = ({items}) => { |
| 13 | + return ( |
| 14 | + <BlogSidebarItemList |
| 15 | + items={items} |
| 16 | + ulClassName={clsx(styles.sidebarItemList, 'clean-list')} |
| 17 | + liClassName={styles.sidebarItem} |
| 18 | + linkClassName={styles.sidebarItemLink} |
| 19 | + linkActiveClassName={styles.sidebarItemLinkActive} |
| 20 | + /> |
| 21 | + ); |
| 22 | +}; |
| 23 | +function BlogSidebarDesktop({sidebar}) { |
| 24 | + const items = useVisibleBlogSidebarItems(sidebar.items); |
| 25 | + return ( |
| 26 | + <aside className="col col--3"> |
| 27 | + <nav |
| 28 | + className={clsx(styles.sidebar, 'thin-scrollbar')} |
| 29 | + aria-label={translate({ |
| 30 | + id: 'theme.blog.sidebar.navAriaLabel', |
| 31 | + message: 'Blog recent posts navigation', |
| 32 | + description: 'The ARIA label for recent posts in the blog sidebar', |
| 33 | + })}> |
| 34 | + <div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}> |
| 35 | + <Link to="/blog">{sidebar.title}</Link> |
| 36 | +</div> |
| 37 | + |
| 38 | + <BlogSidebarContent |
| 39 | + items={items} |
| 40 | + ListComponent={ListComponent} |
| 41 | + yearGroupHeadingClassName={styles.yearGroupHeading} |
| 42 | + /> |
| 43 | + </nav> |
| 44 | + </aside> |
| 45 | + ); |
| 46 | +} |
| 47 | +export default memo(BlogSidebarDesktop); |
0 commit comments