tags.go (1782B)
1 package utils 2 3 import "strings" 4 5 var tagClassMap = map[string]string{ 6 // Languages 7 "Zig": "lang-zig", 8 "Rust": "lang-rust", 9 "C": "lang-c", 10 "Go": "lang-go", 11 "TypeScript": "lang-ts", 12 "Python": "lang-python", 13 14 // Tools 15 "Zed (Vim mode)": "tool-zed", 16 "Neovim": "tool-neovim", 17 "OpenCode": "tool-opencode", 18 "Linux": "tool-linux", 19 "Fish": "tool-fish", 20 "Ghostty": "tool-ghostty", 21 22 // Interests 23 "Low-level systems": "interest-lowlevel", 24 "TUI/CLI tooling": "interest-tui", 25 "Embedded": "interest-embedded", 26 "UNIX philosophy": "interest-unix", 27 28 // Tech 29 "Temporal": "tech-temporal", 30 "PostgreSQL": "tech-postgres", 31 "PyTorch": "tech-pytorch", 32 "CUDA": "tech-cuda", 33 "Docker": "tech-docker", 34 "Kafka": "tech-kafka", 35 "React Native": "tech-rn", 36 "Supabase": "tech-supabase", 37 "REST": "tech-rest", 38 } 39 40 var techAbbreviations = map[string]string{ 41 "TypeScript": "TS", 42 } 43 44 func TagClass(tag string) string { 45 if className, ok := tagClassMap[tag]; ok { 46 return className 47 } 48 49 for knownTag, className := range tagClassMap { 50 if strings.EqualFold(knownTag, tag) { 51 return className 52 } 53 } 54 55 return "" 56 } 57 58 func TechMeta(tech []string) string { 59 if len(tech) == 0 { 60 return "" 61 } 62 63 parts := make([]string, 0, 2) 64 for i, item := range tech { 65 if i >= 2 { 66 break 67 } 68 69 if short, ok := techAbbreviations[item]; ok { 70 parts = append(parts, short) 71 continue 72 } 73 74 short := "" 75 for tech, abbreviation := range techAbbreviations { 76 if strings.EqualFold(tech, item) { 77 short = abbreviation 78 break 79 } 80 } 81 82 if short != "" { 83 parts = append(parts, short) 84 } else { 85 parts = append(parts, item) 86 } 87 } 88 89 return strings.Join(parts, ", ") 90 }