mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-03 01:59:31 +08:00
38 lines
1 KiB
Text
38 lines
1 KiB
Text
import { iconDefaults, fullIcon } from '../icon/index.mjs';
|
|
import { mergeIconData } from '../icon/merge.mjs';
|
|
|
|
function getIconData(data, name, full = false) {
|
|
function getIcon(name2, iteration) {
|
|
if (data.icons[name2] !== void 0) {
|
|
return Object.assign({}, data.icons[name2]);
|
|
}
|
|
if (iteration > 5) {
|
|
return null;
|
|
}
|
|
const aliases = data.aliases;
|
|
if (aliases && aliases[name2] !== void 0) {
|
|
const item = aliases[name2];
|
|
const result2 = getIcon(item.parent, iteration + 1);
|
|
if (result2) {
|
|
return mergeIconData(result2, item);
|
|
}
|
|
return result2;
|
|
}
|
|
const chars = data.chars;
|
|
if (!iteration && chars && chars[name2] !== void 0) {
|
|
return getIcon(chars[name2], iteration + 1);
|
|
}
|
|
return null;
|
|
}
|
|
const result = getIcon(name, 0);
|
|
if (result) {
|
|
for (const key in iconDefaults) {
|
|
if (result[key] === void 0 && data[key] !== void 0) {
|
|
result[key] = data[key];
|
|
}
|
|
}
|
|
}
|
|
return result && full ? fullIcon(result) : result;
|
|
}
|
|
|
|
export { getIconData };
|