mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-08-29 09:28:23 +02:00
* Add directory * Add lab check script * Delete duplicated icons * Fix the lab page * Adjust paths * update lockfile * update lockfile * fix(lab/planet): replace with guideline-compliant design * Add install step * Add second install step * Adjust lab in site * try this * Fix workflow * Add cspell * Format code * Temporary delete icons for copilot review * Place back lab icons * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Update lock file * Revert svg changes * Fix list * Rename filenames * Format tsconfig --------- Co-authored-by: Karsa <contact@karsa.org> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
31 lines
861 B
TypeScript
31 lines
861 B
TypeScript
import { eventHandler, getQuery, setResponseHeader } from 'h3';
|
|
import iconNodes from '../../../data/lab/iconNodes';
|
|
type IconNodeWithKeys = [elementName: string, attrs: Record<string, string> & { key?: string }][];
|
|
|
|
export default eventHandler((event) => {
|
|
const query = getQuery(event);
|
|
|
|
const withUniqueKeys = query.withUniqueKeys === 'true';
|
|
|
|
setResponseHeader(event, 'Cache-Control', 'public, max-age=86400');
|
|
setResponseHeader(event, 'Access-Control-Allow-Origin', '*');
|
|
|
|
if (withUniqueKeys) {
|
|
return iconNodes;
|
|
}
|
|
|
|
return Object.entries(iconNodes).reduce((acc, [name, iconNode]) => {
|
|
if (withUniqueKeys) {
|
|
return [name, iconNode];
|
|
}
|
|
|
|
const newIconNode = (iconNode as IconNodeWithKeys).map(([name, { key, ...attrs }]) => {
|
|
return [name, attrs];
|
|
});
|
|
|
|
acc[name] = newIconNode;
|
|
|
|
return acc;
|
|
}, {});
|
|
});
|