From 36ab5be3c2a7008b48c632bed4512a15d097a877 Mon Sep 17 00:00:00 2001 From: TerryM Date: Fri, 5 Jun 2026 01:07:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(categories):=20hide=20the=20=E7=BB=BC?= =?UTF-8?q?=E5=90=88=20(general)=20category=20from=20the=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both the categories page grid and the home categories carousel now filter out the 'general' slug before sorting. The full backend list is still kept in state so posts that resolve their label via the categories lookup don't lose their name. Backend will follow up by dropping the slug from /api/categories; this client-side filter then becomes a defensive no-op. --- src/pages/Categories/index.tsx | 12 ++++++++---- src/pages/Home/index.tsx | 11 +++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pages/Categories/index.tsx b/src/pages/Categories/index.tsx index 2edbe83..a1ac617 100644 --- a/src/pages/Categories/index.tsx +++ b/src/pages/Categories/index.tsx @@ -23,9 +23,13 @@ const FIGMA_CATEGORY_ORDER = [ "official-assets", "media-coverage", "academy-video", - "general", ]; +// Categories the design no longer surfaces on this page. The backend still +// returns them (and posts may still resolve their category names via the full +// list) but they should never appear in the visible grid. +const HIDDEN_CATEGORY_SLUGS = new Set(["general"]); + function figmaCategoryRank(category: Category): number { const index = FIGMA_CATEGORY_ORDER.indexOf(category.slug); return index === -1 ? FIGMA_CATEGORY_ORDER.length : index; @@ -45,9 +49,9 @@ export function CategoriesPage() { )}`; const applyCategories = (items: Category[]) => setCats( - itemsOrEmpty(items).sort( - (a, b) => figmaCategoryRank(a) - figmaCategoryRank(b), - ), + itemsOrEmpty(items) + .filter((cat) => !HIDDEN_CATEGORY_SLUGS.has(cat.slug)) + .sort((a, b) => figmaCategoryRank(a) - figmaCategoryRank(b)), ); setErr(null); diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index 3cfe9ac..a40d8fb 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -33,9 +33,12 @@ const FIGMA_CATEGORY_ORDER = [ "official-assets", "media-coverage", "academy-video", - "general", ]; +// Hidden from the home categories carousel but still kept in the lookup map +// so posts in these categories can still resolve their category label. +const HIDDEN_CATEGORY_SLUGS = new Set(["general"]); + function figmaCategoryRank(category: Category): number { const index = FIGMA_CATEGORY_ORDER.indexOf(category.slug); return index === -1 ? FIGMA_CATEGORY_ORDER.length : index; @@ -214,9 +217,9 @@ export function Home() { }; }, [lang]); - const figmaOrderedCategories = [...cats].sort( - (a, b) => figmaCategoryRank(a) - figmaCategoryRank(b), - ); + const figmaOrderedCategories = cats + .filter((cat) => !HIDDEN_CATEGORY_SLUGS.has(cat.slug)) + .sort((a, b) => figmaCategoryRank(a) - figmaCategoryRank(b)); const categoryPages: Category[][] = []; for (let index = 0; index < figmaOrderedCategories.length; index += 9) {