Files
lucide/docs/.vitepress/lib/icons.ts
Han Yeong-woo eb035fe370 Improve formatting (#1814)
* Ignore linting for examples in docs

* Formatting JSX single attribute per line

* Separte `format` and `lint:format` in package.json

* Bump prettier version

* Run format
2024-02-01 14:38:21 +01:00

48 lines
1.1 KiB
TypeScript

import fs from 'fs';
import path from 'path';
import { IconNodeWithKeys } from '../theme/types';
import iconNodes from '../data/iconNodes';
import releaseMeta from '../data/releaseMetaData.json';
const DATE_OF_FORK = '2020-06-08T16:39:52+0100';
const directory = path.join(process.cwd(), '../icons');
export interface GetDataOptions {
withChildKeys?: boolean;
}
export async function getData(name: string) {
const jsonPath = path.join(directory, `${name}.json`);
const jsonContent = fs.readFileSync(jsonPath, 'utf8');
const { tags, categories, contributors } = JSON.parse(jsonContent);
const iconNode = iconNodes[name];
const releaseData = releaseMeta?.[name] ?? {
createdRelease: {
version: '0.0.0',
date: DATE_OF_FORK,
},
changedRelease: {
version: '0.0.0',
date: DATE_OF_FORK,
},
};
return {
name,
tags,
categories,
iconNode,
contributors,
...releaseData,
};
}
export async function getAllData(): Promise<{ name: string; iconNode: IconNodeWithKeys }[]> {
const names = Object.keys(iconNodes);
return Promise.all(names.map((name) => getData(name)));
}