'use strict'; // Inline SVG icons at build time. // Templates: <%- icon('si:gitlab') %> / <%- icon('lucide:map-pin') %> // Markdown: {% icon lucide:download %} // si: Simple Icons (brand logos) https://simpleicons.org // lucide: Lucide (general icons) https://lucide.dev // custom: themes/openalt/icons/*.svg (logos missing from the above, e.g. LinkedIn) const fs = require('fs'); const path = require('path'); const sets = { si: path.join(hexo.base_dir, 'node_modules/simple-icons/icons'), lucide: path.join(hexo.base_dir, 'node_modules/lucide-static/icons'), custom: path.join(hexo.theme_dir, 'icons') }; const cache = new Map(); function icon(name) { if (!name) return ''; if (cache.has(name)) return cache.get(name); const [set, id] = name.split(':'); const dir = sets[set]; const file = dir && id && path.join(dir, id + '.svg'); if (!file || !fs.existsSync(file)) { hexo.log.warn('icon: unknown icon "%s"', name); cache.set(name, ''); return ''; } const svg = fs.readFileSync(file, 'utf8') .replace(//g, '') .replace(/