Blog: add more useful content to the sidebar (tags, authors, feeds, links...)
🚀 Feature
Make the feeds, tags page, archive page, authors page (if the last ever gets implemented) directly visitable from the index page.
Have you read the Contributing Guidelines on issues?
Yes
Has this been requested on Canny?
No
Motivation
- Currently, to visit the tags page, the user has to click on a tag, then click "view all tags"—that's two layers of Indirection.
- For the feeds, afaik there's currently no way to access them (besides typing in the URL, of course, given that you know where the file lives), or any indication that they even exist.
- From the current status of #5428 (I understand it's still underdeveloped), it's unlikely that a link will be provided on the index page.
I propose we have a "links group" on the blog index page providing access to all these pages.
API Design
The only place where these links can be tucked in is probably the blog sidebar. The links group can be added below the sidebar title or below the list of post titles. We can even add little icons like "feeds" and "tag" :)
Not sure if it's worth providing options to toggle these links on or off; I guess keeping them won't distort the appearance of the page much anyways
Have you tried building it?
Because I have a swizzled blog page, I directly added the links group below the blog title: https://joshcena.com/blog/
This is actually pretty easy to achieve in the userland (just wrap the existing BlogSidebar, doesn't even require swizzling), but from a design perspective I find it inadequate for this to be missing from the theme itself.
Edit. I was a bit naïve when I believed we could wrap the sidebar. Turns out that the sidebar has fixed position, but the wrapped one doesn't, so for this code:
export default function BlogSidebar(props) {
return (
<>
<OriginalBlogSidebar {...props} />
<div>Links</div>
</>
);
}
The "Links" text just scrolls up when the page is scrolled while the sidebar is fixed. Therefore the user still has to swizzle the Sidebar component, which is undesirable.
Agree that we should do something to make the blog sidebar easier to customize.
I'm thinking we could have blog sidebar items, similar to navbar items (and we should also provide a way to create custom blog sidebar items).
This would require that we create a "sidebar module" with more data in it (that all blog pages would receive) so that the theme sidebar items can use those data.
We could create predefined sidebar items for recent posts, tags, sections with list of links etc... but in the end the user can create its own items to handle specific use-cases.
@sw-yx has a customized sidebar here, as a good example of what is wanted in userland
https://docs.temporal.io/blog

Currently, require swizzling + hardcoded data:
https://github.com/temporalio/documentation/blob/master/src/theme/BlogSidebar/index.js
Hi, floks. Any update here?
Whether the data [1] in the blog plugin can be opened through GlobalData? I noticed that the data[2] in the docs plugin was added to GlobalData.
Just like this data:
[1] content data from blog plugin
[2] global data of docs plugin
@bzp2010 Unfortunately no. We tend to be restricted in using global data because it increases the entire site's load time. Is there a particular reason to add blog data to Global Data? You can enhance the blog plugin to add global data if you need to
We should avoid putting too much data into the global data layer as it increases the site site globally.
In case you want to consume blog data on non-blog pages (like your homepage) I'd like to introduce something new later, allowing individual pages to declare their data requirements. A bit like Gatsby/Next.js already do, but something simpler. But this is not really related to the current issue, and will not be worked on very soon.
Yes, putting all the data into GlobalData is just an expedient measure. I look forward to the new content you will introduce.
Really love to have a similar power of sidebar configuration as we have for docs plugin.
is this issue still live ?
Hi, I'd like to take a stab at this!
Before I start, wanted to confirm the intended direction: is the navbar-item-style config API (as @slorber sketched in the first comment) still the preferred approach? Specifically, something like:
// docusaurus.config.js
blog: {
sidebar: {
items: [
{ type: 'recentPosts' },
{ type: 'tags' },
{ type: 'archive' },
{ type: 'rss' },
],
},
}
Also wondering if there's been any prior work on this that I should be aware of before diving in.
Thanks!
I think that structure is fine.
Just wondering if the sidebar couldn't be the array directly? Apart from items, I don't know if we would ever need any other attribute here. At the same time, nesting it under items is more future-proof.
Maybe try to implement a POC and show us what it could look like? We could iterate on the api design from the PR.
@takenosuke-code are you still working on this? If you are I will leave it to you.
If not, I have a POC ready and can open it.
On the question about whether the sidebar could be the array directly: I kept the object. The reason is that BlogSidebar already has a title next to items, it is rendered by BlogSidebar/Desktop and it is a translated string, so a bare array has nowhere to put it. themeConfig.blog.sidebar.groupByYear is also already a named attribute on a sidebar object, so an array on the plugin side would make the two sides of the same feature different shapes. And it leaves room to move blogSidebarCount and blogSidebarTitle under sidebar later without breaking anything twice.
I also left the recent post list alone rather than making it one item in the array, because groupBlogSidebarItemsByYear and useVisibleBlogSidebarItems assume every item is a dated post, and those are public exports that swizzled sidebars use. So the new links are a separate array next to items, opt in and empty by default.
Does keeping the object match what you had in mind, or would you rather see the flat array?
[1] content data from blog plugin
[2] global data of docs plugin