Я также приветствовал бы встроенную опцию, позволяющую по умолчанию открывать категорию документации с индексной темой. До тех пор я использую следующий JavaScript-обходной путь:
import { apiInitializer } from "discourse/lib/api";
export default apiInitializer((api) => {
// Категории документации: перенаправление списка категорий на индексную тему
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);
}
}
});
});
Чтобы открыть категорию документации со стандартным списком, добавьте параметр в URL:
/c/category-1-slug/category-1-id?list=true