mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-17 14:28:25 +00:00
perf(site): cache related icon names and reuse search indexes (#5123)
* perf(docs): cache name parts when generating related icons * perf(site): reuse icon search indexes between queries --------- Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
This commit is contained in:
co-authored by
Eric Fennis
parent
dbd4b9e5d3
commit
86d3238758
@@ -28,7 +28,7 @@ const nameParts = (icon) =>
|
||||
|
||||
const getRelatedIcons = (currentIcon, icons) => {
|
||||
const iconSimilarity = (item) =>
|
||||
nameWeight * arrayMatches(nameParts(item), nameParts(currentIcon)) +
|
||||
nameWeight * arrayMatches(iconNameParts.get(item), iconNameParts.get(currentIcon)) +
|
||||
categoryWeight * arrayMatches(item.categories ?? [], currentIcon.categories ?? []) +
|
||||
tagWeight * arrayMatches(item.tags ?? [], currentIcon.tags ?? []);
|
||||
|
||||
@@ -54,6 +54,7 @@ const iconsMetaDataPromises = svgFiles.map(async (iconName) => {
|
||||
});
|
||||
|
||||
const iconsMetaData = await Promise.all(iconsMetaDataPromises);
|
||||
const iconNameParts = new Map(iconsMetaData.map((icon) => [icon, nameParts(icon)]));
|
||||
|
||||
const relatedIcons = iconsMetaData.map((icon) => {
|
||||
const iconRelatedIcons = getRelatedIcons(icon, iconsMetaData);
|
||||
|
||||
Reference in New Issue
Block a user