aboutsummaryrefslogtreecommitdiffstats
path: root/src/theme/BlogSidebar/Desktop.tsx
blob: d06f239ec1c2e750a2969d8e277febff9d0609ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 * Copyright (c) 2024 Kristóf Marussy <kristof@marussy.com>
 *
 * SPDX-License-Identifier: MIT
 *
 * This file was derived from
 * https://github.com/facebook/docusaurus/blob/6f17d5493877ba38d8b4e0b0d468f44401375c30/packages/docusaurus-theme-classic/src/theme/BlogSidebar/Desktop/index.tsx
 * via the `swizzle` mechanism of Docusaurus.
 *
 * It was modified to change the sidebar title styling.
 */

import Link from '@docusaurus/Link';
import { translate } from '@docusaurus/Translate';
import { useVisibleBlogSidebarItems } from '@docusaurus/theme-common/internal';
import type { Props } from '@theme/BlogSidebar/Desktop';
import React from 'react';
import clsx from 'clsx';

import styles from './Desktop.module.css';

export default function BlogSidebarDesktop({ sidebar }: Props) {
  const items = useVisibleBlogSidebarItems(sidebar.items);
  return (
    <aside className="col col--3">
      <nav
        className={clsx(styles.sidebar, 'thin-scrollbar')}
        aria-label={translate({
          id: 'theme.blog.sidebar.navAriaLabel',
          message: 'Blog recent posts navigation',
          description: 'The ARIA label for recent posts in the blog sidebar',
        })}
      >
        <div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>
          <span aria-hidden="true">🗓️</span> {sidebar.title}
        </div>
        <ul className={clsx(styles.sidebarItemList, 'clean-list')}>
          {items.map((item) => (
            <li key={item.permalink} className={styles.sidebarItem}>
              <Link
                isNavLink
                to={item.permalink}
                className={styles.sidebarItemLink}
                activeClassName={styles.sidebarItemLinkActive}
              >
                {item.title}
              </Link>
            </li>
          ))}
        </ul>
      </nav>
    </aside>
  );
}