refactor(scripts): pull in separate categories.schema.json (#1658)

This commit is contained in:
Hammy authored and GitHub committed 2025-03-20 08:39:11 -04:00
1 parent ef1a2be3c2
commit ac0f3f6677
8 files changed
+106 -99

No files matched your search

+4 -4
View File
@@ -1,4 +1,4 @@
import type { PortsSchema, UserstylesSchema } from "@/types/mod.ts";
import type { CategoriesSchema, UserstylesSchema } from "@/types/mod.ts";
import { REPO_ROOT } from "@/constants.ts";
import * as path from "@std/path";
@@ -14,9 +14,9 @@ type MappedPorts = {
export async function generateMainReadme(
userstyles: UserstylesSchema.Userstyles,
portsData: PortsSchema.PortsSchema,
categoriesData: CategoriesSchema.CategoryDefinitions,
) {
if (!portsData.categories) throw ("Ports data is missing categories");
if (!categoriesData) throw ("Categories data is missing categories");
const categorized = Object.entries(userstyles)
.reduce((acc, [slug, { categories, ...port }]) => {
@@ -37,7 +37,7 @@ export async function generateMainReadme(
return acc;
}, {} as MappedPorts);
const portListData = portsData.categories
const portListData = categoriesData
.filter((category) => categorized[category.key] !== undefined)
.map((category) => {
return { meta: category, ports: categorized[category.key] };