feat(categories): hide the 综合 (general) category from the UI
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 33s

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.
This commit is contained in:
TerryM
2026-06-05 01:07:40 +08:00
parent 1b52a6d93d
commit 36ab5be3c2
2 changed files with 15 additions and 8 deletions

View File

@@ -23,9 +23,13 @@ const FIGMA_CATEGORY_ORDER = [
"official-assets", "official-assets",
"media-coverage", "media-coverage",
"academy-video", "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 { function figmaCategoryRank(category: Category): number {
const index = FIGMA_CATEGORY_ORDER.indexOf(category.slug); const index = FIGMA_CATEGORY_ORDER.indexOf(category.slug);
return index === -1 ? FIGMA_CATEGORY_ORDER.length : index; return index === -1 ? FIGMA_CATEGORY_ORDER.length : index;
@@ -45,9 +49,9 @@ export function CategoriesPage() {
)}`; )}`;
const applyCategories = (items: Category[]) => const applyCategories = (items: Category[]) =>
setCats( setCats(
itemsOrEmpty(items).sort( itemsOrEmpty(items)
(a, b) => figmaCategoryRank(a) - figmaCategoryRank(b), .filter((cat) => !HIDDEN_CATEGORY_SLUGS.has(cat.slug))
), .sort((a, b) => figmaCategoryRank(a) - figmaCategoryRank(b)),
); );
setErr(null); setErr(null);

View File

@@ -33,9 +33,12 @@ const FIGMA_CATEGORY_ORDER = [
"official-assets", "official-assets",
"media-coverage", "media-coverage",
"academy-video", "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 { function figmaCategoryRank(category: Category): number {
const index = FIGMA_CATEGORY_ORDER.indexOf(category.slug); const index = FIGMA_CATEGORY_ORDER.indexOf(category.slug);
return index === -1 ? FIGMA_CATEGORY_ORDER.length : index; return index === -1 ? FIGMA_CATEGORY_ORDER.length : index;
@@ -214,9 +217,9 @@ export function Home() {
}; };
}, [lang]); }, [lang]);
const figmaOrderedCategories = [...cats].sort( const figmaOrderedCategories = cats
(a, b) => figmaCategoryRank(a) - figmaCategoryRank(b), .filter((cat) => !HIDDEN_CATEGORY_SLUGS.has(cat.slug))
); .sort((a, b) => figmaCategoryRank(a) - figmaCategoryRank(b));
const categoryPages: Category[][] = []; const categoryPages: Category[][] = [];
for (let index = 0; index < figmaOrderedCategories.length; index += 9) { for (let index = 0; index < figmaOrderedCategories.length; index += 9) {