// static/js/langIcons.js // Bold, distinctive icons for document languages / file types. Each icon // fills the 24×24 viewBox with a recognisable silhouette — no fragile little // inset-on-a-page-outline approach. Designed to read clearly at 12–14px. const ICONS = { // Markdown — the official "M↓" logo silhouette, simplified. markdown: '' + '' + '' + '', // CSV — bold 3-column spreadsheet csv: '' + '' + '' + '' + '', // Python — interlocking double-snake silhouette (simplified) python: '' + '' + '', // HTML — bold angle-bracket code: html: '' + '' + '', // JSON — bold { } json: '' + '', // JavaScript — JS letters in a rounded badge javascript: '' + '' + '', // TypeScript — TS in a rounded badge typescript: '' + '' + '', // YAML — bold indented bullet list yaml: '' + '' + '' + '' + '' + '', // CSS — # symbol big and bold css: '' + '' + '' + '', // Bash / shell — terminal window with > prompt + cursor bash: '' + '' + '', sh: '' + '' + '', // SQL — database cylinder sql: '' + '' + '' + '', // PDF — doc with bold "PDF" block pdf: '' + '' + '' + '' + '' + '' + '', // Email — bold envelope email: '' + '', // XML — angle brackets like HTML xml: '' + '' + '', // SVG — overlapping geometric shapes svg: '' + '' + '', // Rust — gear / cog (Rust's mark is a gear with R inside) rust: '' + '' + '', // Go — gopher face (circle with two eyes + smile) go: '' + '' + '' + '', // Java — coffee cup with steam (Java = coffee) java: '' + '' + '' + '', // C — bold open arc c: '', // C++ — C + two plus signs cpp: '' + '' + '' + '' + '', // C# — C + sharp (♯) csharp: '' + '' + '' + '' + '', // Ruby — gem with cut facets ruby: '' + '' + '' + '' + '' + '', // PHP — stylised elephant (PHP's mascot, simplified) php: '' + '' + '' + '', // Generic code fallback (used by toml/ini already; left as-is) code: '' + '', }; const ALIASES = { md: 'markdown', py: 'python', htm: 'html', js: 'javascript', ts: 'typescript', yml: 'yaml', shell: 'bash', zsh: 'bash', 'c++': 'cpp', 'c#': 'csharp', rs: 'rust', rb: 'ruby', toml: 'yaml', ini: 'yaml', }; /** * Return SVG markup for the given language/type, or '' if unknown. * @param {string} lang language name (case-insensitive) * @param {number} [size] pixel width/height of the rendered SVG (default 14) * @param {object} [opts] { className, style } extra attrs on the */ export function langIcon(lang, size = 14, opts = {}) { if (!lang) return ''; const key = String(lang).toLowerCase(); const inner = ICONS[key] || ICONS[ALIASES[key]] || ''; if (!inner) return ''; const cls = (opts && opts.className) ? ` class="${opts.className}"` : ''; const style = (opts && opts.style) ? ` style="${opts.style}"` : ''; return ( `` + `${inner}` ); } export default { langIcon };