Skip to content

Commit 13607f1

Browse files
committed
fix: make 'All posts' blog sidebar heading clickable (#117)
Signed-off-by: Sarthak Lole <lolesarthak@gmail.com>
1 parent 87eb2e3 commit 13607f1

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.sidebar {
2+
max-height: calc(100vh - (var(--ifm-navbar-height) + 2rem));
3+
overflow-y: auto;
4+
position: sticky;
5+
top: calc(var(--ifm-navbar-height) + 2rem);
6+
}
7+
8+
.sidebarItemTitle {
9+
font-size: var(--ifm-h3-font-size);
10+
font-weight: var(--ifm-font-weight-bold);
11+
}
12+
13+
.sidebarItemList {
14+
font-size: 0.9rem;
15+
}
16+
17+
.sidebarItem {
18+
margin-top: 0.7rem;
19+
}
20+
21+
.sidebarItemLink {
22+
color: var(--ifm-font-color-base);
23+
display: block;
24+
}
25+
26+
.sidebarItemLink:hover {
27+
text-decoration: none;
28+
}
29+
30+
.sidebarItemLinkActive {
31+
color: var(--ifm-color-primary) !important;
32+
}
33+
34+
@media (max-width: 996px) {
35+
.sidebar {
36+
display: none;
37+
}
38+
}
39+
40+
.yearGroupHeading {
41+
margin-top: 1.6rem;
42+
margin-bottom: 0.4rem;
43+
}

0 commit comments

Comments
 (0)