feat(categories): hide the 综合 (general) category from the UI
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 33s
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:
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user