/
githubmirror
/
hexo
Обзор
Документация
Войти
/
githubmirror
/
hexo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lib/plugins/helper/css.ts
38 строк
983 B
D-Sketon
perf: fix potential cache miss issues with moize (#5694)
30 сен 2025, 20:26
Не верифицирован
30 сен 2025, 20:26
6af02f7
Код
Авторство
О чём код?
import { htmlTag, url_for } from 'hexo-util'; import moize from 'moize'; import type { LocalsType } from '../../types'; let relative_link = true; function cssHelper(this: LocalsType, ...args: any[]) { let result = '\n'; relative_link = this.config.relative_link; args.flat(Infinity).forEach(item => { if (typeof item === 'string' || item instanceof String) { let path = item; if (!path.endsWith('.css')) { path += '.css'; } result += `<link rel="stylesheet" href="${url_for.call(this, path)}">\n`; } else { const newItem = { rel: 'stylesheet', ...item }; // Custom attributes newItem.href = url_for.call(this, newItem.href); if (!newItem.href.endsWith('.css')) newItem.href += '.css'; result += htmlTag('link', newItem) + '\n'; } }); return result; } export = moize(cssHelper, { maxSize: 10, isDeepEqual: true, updateCacheForKey() { return relative_link; } });