0ab2c58eb4
- Header desktop nav: social icons grouped in a wald-tinted pill with labels, active-state (aria-current + bold), opacity hover (no per-item bg) - Mobile overlay: social links as icon+label rows with active-state - Search button: lucide:search, icon-only - Migrate all icons mdi→lucide app-wide (234 refs); brand/language logos (google, whatsapp, mastodon, telegram, language-*) stay on mdi - generate-icons: emit mdi + lucide subsets; add @iconify-json/lucide - iconify-offline: register lucide collection - scripts/icon-map|validate|apply: reusable migration tooling Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
// Rewrite `mdi:NAME` -> `lucide:MAPPED` across frontend src + CMS content.
|
|
// KEEP_MDI names are left untouched (brand/language logos with no lucide pendant).
|
|
import { MAP, KEEP_MDI } from './icon-map.mjs';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const WEB_ROOT = path.resolve(ROOT, '..');
|
|
|
|
const TARGETS = [
|
|
{ dir: path.join(ROOT, 'src'), exts: /\.(svelte|ts|tsx|js|mjs)$/ },
|
|
{ dir: path.join(WEB_ROOT, 'cms_content', 'windwiderstand'), exts: /\.json5$/ },
|
|
];
|
|
const SKIP_DIR = /(node_modules|\.history|\.search|_legacy|\.svelte-kit)/;
|
|
|
|
const stats = { files: 0, repl: 0, kept: {} };
|
|
|
|
function walk(dir, exts, acc) {
|
|
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
if (e.name.startsWith('.') && e.name !== '.') continue;
|
|
const full = path.join(dir, e.name);
|
|
if (SKIP_DIR.test(full)) continue;
|
|
if (e.isDirectory()) walk(full, exts, acc);
|
|
else if (exts.test(e.name)) acc.push(full);
|
|
}
|
|
return acc;
|
|
}
|
|
|
|
const RE = /mdi:([a-z0-9-]+)/g;
|
|
for (const { dir, exts } of TARGETS) {
|
|
if (!fs.existsSync(dir)) continue;
|
|
for (const file of walk(dir, exts, [])) {
|
|
const src = fs.readFileSync(file, 'utf8');
|
|
let n = 0;
|
|
const out = src.replace(RE, (m, name) => {
|
|
if (KEEP_MDI.has(name)) {
|
|
stats.kept[name] = (stats.kept[name] || 0) + 1;
|
|
return m;
|
|
}
|
|
const l = MAP[name];
|
|
if (!l) return m; // unknown -> leave, validator should have caught
|
|
n++;
|
|
return `lucide:${l}`;
|
|
});
|
|
if (n > 0) {
|
|
fs.writeFileSync(file, out);
|
|
stats.files++;
|
|
stats.repl += n;
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log(`rewrote ${stats.repl} refs in ${stats.files} files`);
|
|
console.log('kept on mdi:', JSON.stringify(stats.kept));
|