refactor: convert single category to multiple categories (#559)

ref: https://github.com/catppuccin/catppuccin/commit/35662dbfb46b23d63eca9d3794cdc107c8ff92d3

Co-authored-by: isabel <[email protected]>
This commit is contained in:
Hamothyandisabel authored and GitHub committed 2024-02-28 21:14:52 +00:00
1 parent f7598a1c91
commit cec8bc9d8e
7 files changed
+232 -143

No files matched your search

+5 -4
View File
@@ -18,14 +18,15 @@ export const generateMainReadme = async (
if (!portsData.categories) throw ("Ports data is missing categories");
const categorized = Object.entries(userstyles)
.reduce((acc, [slug, { category, ...port }]) => {
.reduce((acc, [slug, { categories, ...port }]) => {
// initialize category array if it doesn't exist
acc[category] ??= [];
// only care about the first (primary) category in the categories array
acc[categories[0]] ??= [];
acc[category].push({ path: `styles/${slug}`, category, ...port });
acc[categories[0]].push({ path: `styles/${slug}`, categories, ...port });
// Sort by name, first array entry if necessary
acc[category].sort((a, b) =>
acc[categories[0]].sort((a, b) =>
[a.name].flat()[0].localeCompare([b.name].flat()[0])
);
return acc;