mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-12-04 17:09:07 +00:00
* Add category descriptions Co-authored-by: ericfennis <11825403+ericfennis@users.noreply.github.com> * Fix sports category icon * Fix notifications category title * Improve categories * Update descriptions to include periods Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ericfennis <11825403+ericfennis@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import { Category, IconEntity } from '../theme/types';
|
|
|
|
const directory = path.join(process.cwd(), '../categories');
|
|
|
|
export function getAllCategoryFiles(): Omit<Category, 'iconCount'>[] {
|
|
const fileNames = fs.readdirSync(directory).filter((file) => path.extname(file) === '.json');
|
|
|
|
return fileNames.map((fileName) => {
|
|
const name = path.basename(fileName, '.json');
|
|
const fileContent = fs.readFileSync(path.join(directory, fileName), 'utf8');
|
|
|
|
const parsedFileContent = JSON.parse(fileContent);
|
|
|
|
return {
|
|
name,
|
|
title: parsedFileContent.title,
|
|
description: parsedFileContent.description,
|
|
};
|
|
});
|
|
}
|
|
|
|
export function mapCategoryIconCount(
|
|
categories: Omit<Category, 'iconCount'>[],
|
|
icons: { categories: IconEntity['categories'] }[],
|
|
): Category[] {
|
|
return categories.map((category) => ({
|
|
...category,
|
|
iconCount: icons.reduce(
|
|
(acc, curr) => (curr.categories.includes(category.name) ? ++acc : acc),
|
|
0,
|
|
),
|
|
}));
|
|
}
|