Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import fs from 'node:fs';
import path from 'node:path';
import { type IconSet } from './icon-catalog';
export function keywordsFromMetadata(rootDir: string, set: IconSet, name: string): string {
const filePath = path.join(rootDir, 'model', 'metadata', set, `${name}.json`);
if (!fs.existsSync(filePath)) {
return name;
}
try {
const raw = JSON.parse(fs.readFileSync(filePath, 'utf8')) as { synonyms?: unknown };
const synonyms = Array.isArray(raw.synonyms)
? raw.synonyms.filter((s): s is string => typeof s === 'string')
: [];
return [name, ...synonyms].join(' ');
} catch (error) {
console.warn('Could not read icon keywords', { filePath, error });
return name;
}
}
|