Home

simpleicons @main - refs - log - search -
https://git.jolheiser.com/simpleicons.git
Go library for simpleicons.org
index.ts - raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import * as icons from 'simple-icons';

let structs = "";
let map = "";
for (const [name, icon] of Object.entries(icons)) {
  const varName = "SI" + icon.slug.charAt(0).toUpperCase() + icon.slug.slice(1);   
  structs += varName + ` = Icon{
      Title: "${icon.title}",
      Slug: "${icon.slug}",
      Hex: "${icon.hex}",
      Path: "${icon.path}",
    }
    `
  map += `"${icon.slug}": ${varName},
  `
}

let tmpl = `package simpleicons

import "fmt"

// Icon is a SimpleIcon
type Icon struct {
  Title string
  Slug  string
  Hex   string
  Path  string
}

// SVG returns a complete SVG for the Icon
func (i Icon) SVG() string {
  return fmt.Sprintf(` + "`" + `<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>%s</title><path d="%s"/></svg>` + "`" + `, i.Title, i.Path)
}

var (
  ${structs}
  Icons = map[string]Icon{
  ${map}
}
)
`
const path = "./simpleicons.go";
await Bun.write(path, tmpl);