Skip to content
Source
Sign inSign up

markdownLinkIcons.ts

22 lines904 Bytes

1import {
2 isMonochromeSourceControlIcon,
3 sourceControlClients,
4} from "@t3tools/client-runtime/source-control-clients";
5import type { ImageSourcePropType } from "react-native";
6​
7import { SOURCE_CONTROL_LINK_ICON_SOURCES } from "./markdownLinkIcons.generated";
8​
9export interface MarkdownLinkIcon {
10 readonly source: ImageSourcePropType;
11 /** A mark drawn in the text colour takes the link's colour; a coloured mark keeps its own. */
12 readonly tints: boolean;
14​
15// `vp run sync:link-icons` renders each host's artwork into the bundled image this reads.
16export function markdownLinkIcon(host: string): MarkdownLinkIcon | null {
17 const definition = sourceControlClients.findByPublicDomain(host);
18 const source = definition && SOURCE_CONTROL_LINK_ICON_SOURCES[definition.kind];
19 return definition?.icon && source
20 ? { source, tints: isMonochromeSourceControlIcon(definition.icon) }
21 : null;