|
28 | 28 | #fa-icon(icon) #link(link_prefix + username)[#username]
|
29 | 29 | ]
|
30 | 30 |
|
| 31 | + let custom-social(icon, dest, body) = [ |
| 32 | + #fa-icon(icon) #link(dest, body) |
| 33 | + ] |
| 34 | + |
| 35 | + let socialsDict = ( |
| 36 | + // key: (faIcon, linkPrefix) |
| 37 | + phone: ("phone", "tel:"), |
| 38 | + email: ("envelope", "mailto:"), |
| 39 | + github: ("github", "https://github.com/"), |
| 40 | + linkedin: ("linkedin", "https://linkedin.com/in/"), |
| 41 | + x: ("x-twitter", "https://twitter.com/"), |
| 42 | + bluesky: ("bluesky", "https://bsky.app/profile/"), |
| 43 | + ) |
| 44 | + |
31 | 45 | let socialsList = ()
|
32 |
| - if "phone" in socials { |
33 |
| - socialsList.push(social("phone", "tel:", socials.phone)) |
34 |
| - } |
35 |
| - if "email" in socials { |
36 |
| - socialsList.push(social("envelope", "mailto:", socials.email)) |
37 |
| - } |
38 |
| - if "github" in socials { |
39 |
| - socialsList.push(social("github", "https://github.com/", socials.github)) |
40 |
| - } |
41 |
| - if "linkedin" in socials { |
42 |
| - socialsList.push( |
43 |
| - social("linkedin", "https://linkedin.com/in/", socials.linkedin), |
44 |
| - ) |
| 46 | + for entry in socials { |
| 47 | + assert(type(entry) == array, message: "Invalid social entry type.") |
| 48 | + assert(entry.len() == 2, message: "Invalid social entry length.") |
| 49 | + let (key, value) = entry |
| 50 | + if type(value) == str { |
| 51 | + if key not in socialsDict { |
| 52 | + panic("Unknown social key: " + key) |
| 53 | + } |
| 54 | + let (icon, linkPrefix) = socialsDict.at(key) |
| 55 | + socialsList.push(social(icon, linkPrefix, value)) |
| 56 | + } else if type(value) == array { |
| 57 | + assert(value.len() == 3, message: "Invalid social entry: " + key) |
| 58 | + let (icon, dest, body) = value |
| 59 | + socialsList.push(custom-social(icon, dest, body)) |
| 60 | + } else { |
| 61 | + panic("Invalid social entry: " + entry) |
| 62 | + } |
45 | 63 | }
|
46 | 64 |
|
47 | 65 | let socialStack = stack(
|
|
0 commit comments