Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix(website): type community registry data module for astro check

tt-a1i384845e1b7ca
diff --git a/website/src/data/community.mjs b/website/src/data/community.mjs
deleted file mode 100644
index 1ad54101..00000000
--- a/website/src/data/community.mjs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Derived from the community registry — community/packages/*.json is the
-// single source of truth; this page never hand-copies package metadata.
-// import.meta.glob is resolved by Vite at build time relative to this source
-// file, so the catalog cannot drift from the registry.
-
-const modules = import.meta.glob('../../../community/packages/*.json', { eager: true, import: 'default' });
-
-export const packages = Object.entries(modules)
- .map(([file, value]) => {
- if (!file.endsWith(`/${value.name}.json`)) {
- throw new Error(`community registry: ${file} does not match name "${value.name}"`);
- }
- return value;
- })
- .sort((a, b) => a.name.localeCompare(b.name));
-
-export const typeOrder = ['skill', 'recipe', 'brand-marks', 'locale', 'wrapper'];
-export const typeCounts = Object.fromEntries([
- ['all', packages.length],
- ...typeOrder.map((type) => [type, packages.filter((entry) => entry.type === type).length]),
-]);
diff --git a/website/src/data/community.ts b/website/src/data/community.ts
new file mode 100644
index 00000000..9412bc79
--- /dev/null
+++ b/website/src/data/community.ts
@@ -0,0 +1,37 @@
+// Derived from the community registry — community/packages/*.json is the
+// single source of truth; this page never hand-copies package metadata.
+// import.meta.glob is resolved by Vite at build time relative to this source
+// file, so the catalog cannot drift from the registry.
+
+export const PACKAGE_TYPES = ['skill', 'recipe', 'brand-marks', 'locale', 'wrapper'] as const;
+export type PackageType = (typeof PACKAGE_TYPES)[number];
+
+export interface CommunityPackage {
+ name: string;
+ type: PackageType;
+ summary: { en: string; zh: string };
+ author: { name: string; url?: string };
+ repository: string;
+ archify: string;
+ schemaVersions: number[];
+ homepage?: string;
+ tags?: string[];
+ evidence?: { label: string; url: string }[];
+}
+
+const modules = import.meta.glob<CommunityPackage>('../../../community/packages/*.json', { eager: true, import: 'default' });
+
+export const packages: CommunityPackage[] = Object.entries(modules)
+ .map(([file, value]) => {
+ if (!file.endsWith(`/${value.name}.json`)) {
+ throw new Error(`community registry: ${file} does not match name "${value.name}"`);
+ }
+ return value;
+ })
+ .sort((a, b) => a.name.localeCompare(b.name));
+
+export const typeOrder: PackageType[] = [...PACKAGE_TYPES];
+export const typeCounts: Record<'all' | PackageType, number> = Object.fromEntries([
+ ['all', packages.length],
+ ...typeOrder.map((type) => [type, packages.filter((entry) => entry.type === type).length]),
+]) as Record<'all' | PackageType, number>;
diff --git a/website/src/pages/community.astro b/website/src/pages/community.astro
index aea5af38..e4fd143b 100644
--- a/website/src/pages/community.astro
+++ b/website/src/pages/community.astro
@@ -1,13 +1,13 @@
---
import { version, versioned } from '../data/site';
-import { packages, typeOrder, typeCounts } from '../data/community.mjs';
+import { packages, typeOrder, typeCounts, type PackageType } from '../data/community';
import SiteLayout from '../layouts/SiteLayout.astro';
import Navigation from '../components/Navigation.astro';
import head from '../data/community-head.html?raw';
import css from '../styles/community.css?raw';
import pageScript from '../scripts/community.js?raw';
-const typeLabels: Record<string, { en: string; zh: string }> = {
+const typeLabels: Record<PackageType, { en: string; zh: string }> = {
skill: { en: 'Skill pack', zh: '技能包' },
recipe: { en: 'Recipes', zh: '场景配方' },
'brand-marks': { en: 'Brand kit', zh: '品牌套件' },