Add function that exports all icons

This commit is contained in:
Kuba Orlik 2026-08-06 10:48:48 +02:00
parent 082d429ca2
commit a487efbc74

View File

@ -4,6 +4,8 @@ import _locreq from "locreq";
const locreq = _locreq(import.meta.dirname);
let all_icon_names: Promise<string[]> | null = null;
const cache = {} as Record<string, Promise<string> | undefined>;
export const svg_icon_path = "src/icons";
@ -26,3 +28,12 @@ export async function icon(icon_name: string) {
return "";
}
}
export async function getAllIconNames() {
if (!all_icon_names) {
all_icon_names = fs
.readdir(locreq.resolve(svg_icon_path))
.then((files) => files.map((file) => path.parse(file).name));
}
return all_icon_names;
}