aboutsummaryrefslogtreecommitdiffstats
path: root/src/theme/BlogSidebar/Desktop.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/theme/BlogSidebar/Desktop.tsx')
-rw-r--r--src/theme/BlogSidebar/Desktop.tsx49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/theme/BlogSidebar/Desktop.tsx b/src/theme/BlogSidebar/Desktop.tsx
index d06f239..9830388 100644
--- a/src/theme/BlogSidebar/Desktop.tsx
+++ b/src/theme/BlogSidebar/Desktop.tsx
@@ -5,22 +5,38 @@
5 * SPDX-License-Identifier: MIT 5 * SPDX-License-Identifier: MIT
6 * 6 *
7 * This file was derived from 7 * This file was derived from
8 * https://github.com/facebook/docusaurus/blob/6f17d5493877ba38d8b4e0b0d468f44401375c30/packages/docusaurus-theme-classic/src/theme/BlogSidebar/Desktop/index.tsx 8 * https://github.com/facebook/docusaurus/blame/16a789904faec6b847356bad40b766a140c84b89/packages/docusaurus-theme-classic/src/theme/BlogSidebar/Desktop/index.tsx
9 * via the `swizzle` mechanism of Docusaurus. 9 * via the `swizzle` mechanism of Docusaurus.
10 * 10 *
11 * It was modified to change the sidebar title styling. 11 * It was modified to change the sidebar title styling.
12 */ 12 */
13 13
14import Link from '@docusaurus/Link'; 14import React, { memo } from 'react';
15import clsx from 'clsx';
15import { translate } from '@docusaurus/Translate'; 16import { translate } from '@docusaurus/Translate';
16import { useVisibleBlogSidebarItems } from '@docusaurus/theme-common/internal'; 17import {
18 useVisibleBlogSidebarItems,
19 BlogSidebarItemList,
20} from '@docusaurus/plugin-content-blog/client';
21import BlogSidebarContent from '@theme/BlogSidebar/Content';
22import type { Props as BlogSidebarContentProps } from '@theme/BlogSidebar/Content';
17import type { Props } from '@theme/BlogSidebar/Desktop'; 23import type { Props } from '@theme/BlogSidebar/Desktop';
18import React from 'react';
19import clsx from 'clsx';
20 24
21import styles from './Desktop.module.css'; 25import styles from './Desktop.module.css';
22 26
23export default function BlogSidebarDesktop({ sidebar }: Props) { 27const ListComponent: BlogSidebarContentProps['ListComponent'] = ({ items }) => {
28 return (
29 <BlogSidebarItemList
30 items={items}
31 ulClassName={clsx(styles.sidebarItemList, 'clean-list')}
32 liClassName={styles.sidebarItem}
33 linkClassName={styles.sidebarItemLink}
34 linkActiveClassName={styles.sidebarItemLinkActive}
35 />
36 );
37};
38
39function BlogSidebarDesktop({ sidebar }: Props) {
24 const items = useVisibleBlogSidebarItems(sidebar.items); 40 const items = useVisibleBlogSidebarItems(sidebar.items);
25 return ( 41 return (
26 <aside className="col col--3"> 42 <aside className="col col--3">
@@ -35,21 +51,14 @@ export default function BlogSidebarDesktop({ sidebar }: Props) {
35 <div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}> 51 <div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>
36 <span aria-hidden="true">🗓️</span> {sidebar.title} 52 <span aria-hidden="true">🗓️</span> {sidebar.title}
37 </div> 53 </div>
38 <ul className={clsx(styles.sidebarItemList, 'clean-list')}> 54 <BlogSidebarContent
39 {items.map((item) => ( 55 items={items}
40 <li key={item.permalink} className={styles.sidebarItem}> 56 ListComponent={ListComponent}
41 <Link 57 yearGroupHeadingClassName={styles.yearGroupHeading}
42 isNavLink 58 />
43 to={item.permalink}
44 className={styles.sidebarItemLink}
45 activeClassName={styles.sidebarItemLinkActive}
46 >
47 {item.title}
48 </Link>
49 </li>
50 ))}
51 </ul>
52 </nav> 59 </nav>
53 </aside> 60 </aside>
54 ); 61 );
55} 62}
63
64export default memo(BlogSidebarDesktop);