모바일에서 카테고리 및 '최신'을 어떻게 볼 수 있나요?

확인해 보니, “카테고리와 최신 주제” 뷰를 강제하기 위해 커스텀 JS 코드를 사용했습니다.

더 나은 방법이 있는지 확인하지는 않았지만, 그들이 사용하는 방법은 다음과 같습니다 (코드를 현대화하고 몇 가지 주석을 추가했습니다):

import { apiInitializer } from "discourse/lib/api";
import CategoriesAndLatestTopics from "discourse/components/categories-and-latest-topics";
import CategoryList from "discourse/models/category-list";
import { MAX_UNOPTIMIZED_CATEGORIES } from "discourse/lib/constants";

export default apiInitializer((api) => {
  // "카테고리와 최신 주제" 뷰를 강제합니다.
  api.modifyClass(
    "component:discovery/categories-display",
    (Superclass) =>
      class extends Superclass {
        get categoriesComponent() {
          if (this.args.parentCategory) {
            return super.categoriesComponent;
          } else {
            return CategoriesAndLatestTopics;
          }
        }
      }
  );

  // 원본과 동일하지만 "this.site.desktopView" 체크를 약간 수정하여,
  // 모바일에서도 최신 주제를 찾을 수 있도록 했습니다.
  api.modifyClass(
    "route:discovery-categories",
    (Superclass) =>
      class extends Superclass {
        async findCategories(parentCategory) {
          let model;

          let style = this.siteSettings.desktop_category_page_style;
          if (this.site.categories.length > MAX_UNOPTIMIZED_CATEGORIES) {
            style = "categories_only";
          }

          if (
            style === "categories_and_latest_topics" ||
            style === "categories_and_latest_topics_created_date"
          ) {
            model = await this._findCategoriesAndTopics(
              "latest",
              parentCategory
            );
          } else if (style === "categories_and_top_topics") {
            model = await this._findCategoriesAndTopics(
              "top",
              parentCategory
            );
          } else {
            PreloadStore.remove("topic_list");
            model = await CategoryList.list(this.store, parentCategory);
          }

          return model;
        }
      }
  );
})

새로운 컴포넌트 → 코드 편집 → JS 탭에 이 코드를 붙여넣어 보세요.
도움이 되는지 알려주세요.