Redirect the landing page for each subcategory to index file by default for documentation categories

Hello Discourse team,

We have started looking into Discourse Doc Categories. It looks very promising. Well done!

One item that I noticed is that the landing page for each sub-category currently shows a list of posts under that subcategory sorted by Latest or other possible sorting options.

While this is an acceptable approach for discussions, I feel it could confuse new non-Discourse users. I was expecting to see the index page as the landing page by default. This will also match the sidebar.

Is it possible to add an option to let the user switch between the two?

With the new settings, when user clicks on the Integrations subcategory from the documentation home page, they will land on this page and see all the content.

Instead of this one:

This should make it easier for the users to discover the structure of the documents and find what their need quickly.

6 לייקים

Turns out this has already been requested here. I was looking under the wrong category! :man_facepalming:

Feel free to close/delete this topic. I added my comments to the other post.

6 לייקים

Except the linked topic is not a Vote tracked Feature Topic - so perhaps your Topic should stay?

4 לייקים

I would also welcome a built-in option to have a Doc Category opened with an index topic by default. Until then, I’m using the following JavaScript workaround:

import { apiInitializer } from "discourse/lib/api";

export default apiInitializer((api) => {

    // Doc Categories: redirect category listing to index topic

    api.onPageChange(() => {
        
        const currentPath = window.location.pathname;
        const queryParams = window.location.search;
        
        const redirects = {
            
            "/c/category-1-slug/category-1-id": "/t/topic-1-slug/index-topic-1-id",
            "/c/category-2-slug/category-2-id": "/t/topic-2-slug/index-topic-2-id"
        };
        
        if (queryParams.includes("list=true")) return;
        
        const match = Object.keys(redirects).find(cat => currentPath.startsWith(cat));
        
        if (match) {
          const targetTopic = redirects[match];
          
          if (currentPath !== targetTopic) {

            const router = api.container.lookup("router:main");
            router.transitionTo(targetTopic);
          }
        }
    });

});

To open the Doc Category with the regular listing, add a parameter to the URL:

/c/category-1-slug/category-1-id?list=true
4 לייקים

Nice, looks better to me. I’m currently trying internally an A-Z local rendering and displaying the sidebar automatically on the first attempt to Docs Categories in every session, with the same approach in mind: prevent lazy users from getting lost :slight_smile:

2 לייקים