Fork Horse repository, listed by its owner. Publisher snapshot.

packages/forkhorse-dashboard/src/mark.ts

Snapshot at 34e3175

Containing directory

865 bytes · typescriptView raw
1import brand from "../../../brand.json" with { type: "json" };
2
3const escapeXml = (value: string) => value.replace(/[&<>"']/g, character => ({
4  "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&apos;",
5})[character]!);
6
7/** Identity only: draw text in the viewer's font; distribute no platform emoji artwork. */
8export function markIconUrl(mark: string): string {
9  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" role="img" aria-label="${escapeXml(brand.name)}"><text x="50" y="50" dy=".35em" text-anchor="middle" font-family="Apple Color Emoji, Segoe UI Emoji, Noto Color Emoji, emoji, sans-serif" font-size="84">${escapeXml(mark)}</text></svg>`;
10  // encodeURIComponent leaves apostrophes literal; encode them for either HTML quote style.
11  return `data:image/svg+xml,${encodeURIComponent(svg).replaceAll("'", "%27")}`;
12}
13