Skip to content

feat: Community adders #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions community/unocss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { CommunityAdder } from '../packages/adders/_config/community';

export default {
name: 'UnoCSS',
description: 'The instant on-demand Atomic CSS engine',
category: 'CSS',
npm: 'unocss-svelte-integration',
repo: 'https://github.com/owner-name/repo-name',
website: 'https://unocss.dev',
logo: 'unocss.svg'
} satisfies CommunityAdder;
11 changes: 11 additions & 0 deletions community/unplugin-icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { CommunityAdder } from '../packages/adders/_config/community';

export default {
name: 'unplugin-icons',
description: 'Access thousands of icons as components on-demand universally',
category: 'Icons',
npm: 'unplugin-icons-svelte-integration',
repo: 'https://github.com/owner-name/repo-name',
website: 'https://www.npmjs.com/package/unplugin-icons',
logo: 'unplugin-icons.svg'
} satisfies CommunityAdder;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@types/node": "^22.3.0",
"@vitest/ui": "^2.0.5",
"eslint": "^9.10.0",
"magic-string": "^0.30.11",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.2.6",
"rollup": "^4.21.2",
Expand Down
17 changes: 12 additions & 5 deletions packages/adders/_config/community.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
export type CommunityAdder = {
id: string;
displayName: string;
name: string;
description: string;
package: string;
category: string;
npm: string;
repo: string;
website: string;
logo: string;
};

export type CommunityAdders = CommunityAdder[];
/** EVALUATED AT BUILD TIME */
export const communityAdderIds: string[] = [];

export const communityAdders: CommunityAdders = [];
export async function getCommunityAdders(name: string): Promise<CommunityAdder> {
const { default: details } = await import(`../../../community/${name}.ts`);
return details;
}
2 changes: 1 addition & 1 deletion packages/adders/_config/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { adderIds, adderCategories, getAdderDetails } from './official';
export { categories, type CategoryKeys, type CategoryInfo } from './categories';
export { communityAdders } from './community';
export { getCommunityAdders, communityAdderIds } from './community';
2 changes: 1 addition & 1 deletion packages/adders/_config/official.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const adderDetails = Object.values(categories).flat();
export function getAdderDetails(name: string): AdderWithoutExplicitArgs {
const details = adderDetails.find((a) => a.config.metadata.id === name);
if (!details) {
throw new Error(`invalid adder name: ${name}`);
throw new Error(`Invalid adder name: ${name}`);
}

return details as AdderWithoutExplicitArgs;
Expand Down
Loading